Hi,
I created a constructor "Grade" to let object to pass name and score parameters. However, I don't know how to do it.
Could anyone help me?
Thanks
gogo
#include <iostream>
#include <string>
using namespace std;
class Grade
{
private:
char name[30];
float score;
public:
Grade(char student[], float score);
Grade(void);
int Compare(char s[]);
void Read(void);
};
Grade::Grade(char student[], float score)
{
strcpy(name, student);
Grade::score = score;
}
Grade::Grade()
{
*name = 0;
score = 0.0;
}
Grade::Compare(char s[])
{
int a = 0;
a = strcmp(name, s);
if (a > 0)
{
return 1;
}
else
{
return 0;
}
}
void Grade::Read(void)
{
cout << "Please input your name: ";
cin >> name;
cout << endl;
cout << "Please enter your score: ";
cin >> score;
cout << endl;
}
int main()
{
Grade Students[5](("John", 78.3),("Sally", 86.5),("Bob", 58.9),("Donna", 98.3)); //How to correct it? I want to pass 4 records and let the 5th one to be input from console window.
Read(); //How to call this function?
return 0;
}
P.S.
Also, I found that it is possible to decompile the "class" file of Java to get the source code. Is there any decompiler to decompile the object files created by C/C++?