Home > Back-end >  Have eldest brother to help take a look at this how to solve using visual studio2019 always tip init
Have eldest brother to help take a look at this how to solve using visual studio2019 always tip init

Time:04-22

//for a class a subject overall achievement
//socre class contains name, student id and grades, the final grade, grade, according to the result
//and then define an array of objects stored in a class student performance, at last, by member function call each array element for each student's total grade
# include
# include
using namespace std;
Const double Rate=0.5;
Const int maxN=100;
The class Score
{
Private:
Long No;
String Name;
Int Usual;
Int Final;
Int Total;
Public:
Score (long=0, string *=NULL, int=0, int=0, int=0).
Void the Count ();
Void ShowScore ();
};

Score: : Score (long, string name, int usual, int final, int total)
{
No=No.
Name=Name;
Usual=Usual;
Final=Final;
Total=Total;
}
Void Score: the Count ()
{

Total=Rate + Final Usual * * (1 - Rate) + 0.5;
}
Void Score: : ShowScore ()
{
Cout & lt; }
Int main ()
{
Score MyScore [3].
Score Myscore2 [3]={(2014, "zhang", 88,77), (88, 2015, "bill", 13), (77, 2016, "detective", 13)};
for (int i=0; I & lt; 3; I++)
Myscore2 [I]. The Count ();
for (int i=0; I & lt; 3; I++)
Myscore2 [I] ShowScore ();
return 0;
}

CodePudding user response:

Reference:
 # include 
# include
using namespace std;

Const double Rate=0.5;
Const int maxN=100;
The class Score
{
Private:
Long No;
String Name;
Int Usual;
Int Final;
Int Total;
Public:
Score (long, string, int, int, int).
Void the Count ();
Void ShowScore ();
};

Score: : Score (long no=0, string name="", int usual=0, int final=0, int total=0)
{
No=No.
Name=Name;//Name. Assign (Name);
Usual=Usual;
Final=Final;
Total=Total;
}
Void Score: the Count ()
{
Total=Rate + Final Usual * * (1 - Rate) + 0.5;
}
Void Score: : ShowScore ()
{
Cout & lt; }

Int main ()
{
Score Myscore [3].
Score Myscore2 [3]={Score (2014, "zhang", 88,77), Score (88, 2015, "bill", 13), Score (77, 2016, "detective", 13)};//initialize

for (int i=0; I & lt; 3; I++)
Myscore2 [I]. The Count ();
for (int i=0; I & lt; 3; I++)
Myscore2 [I] ShowScore ();

return 0;
}
  • Related