Help on Classes
Oct 28, 2013 at 6:00am UTC
so i need help in declaring a display function prototype only that displays a student test scores in the format
(student name tab number of scores tab test scores )
is this right?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#ifndef STUDENTTESTSCORES_H
#define STUDENTTESTSCORES_H
#include <string>
using namespace std;
class StudentTestScores{
private :
string studentName;
double *testScores;
int numTestScores;
public :
StudentTestScores(string name = "" , int numScores = 0); // class constructor
StudentTestScores(const StudentTestScores &other); // class copy constructor
~StudentTestScores(); // class destructor
void display(StudentTestScores a)
{
cout << a.studentName << \t << a.numTestScores << \t << a.testScores << endl;
}
};
#endif
and also how do we call the display function if it is in a class from the header file onto the main cpp file.
thank you and help and all help appreciated
Oct 28, 2013 at 8:50am UTC
No, within your class
StudentTestScores
you have all the information to print. Why would you take another
StudentTestScores
to print that information?
In other words:
1 2 3 4
void display(StudentTestScores a)
{
cout << a.studentName << \t << a.numTestScores << \t << a.testScores << endl;
}
[EDIT]
numTestScores isn't a pointer
Last edited on Oct 29, 2013 at 6:53am UTC
Oct 28, 2013 at 5:11pm UTC
ah ok thank you n.n
Topic archived. No new replies allowed.