These are my homework questions. I have attempt to do most of it and I need somebody to check to see if im doing this right.
1. Given the following declaration for a TestScore class, write a derived class declaration called IDScore that adds an integer student ID number as a private member, and that supplies (1) a constructor whose parameters correspond to the three member fields, and (2) an observer that returns the ID number.
class TestScore
{
public:
TestScore(string name, int score);
string GetName() const;
int GetScore() const;
private:
string studentName;
int studentScore;
};
my attempt:
class IDScore : public TestScore
{
public:
IDScore(int studID, int studScore, string studName);
int GetIDNumber() const;
private:
int studentIDNumber;
};
2. Write the implementation file for the TestScore class in Exercise 1. The constructor just assigns its parameters to the private data members, and the observers simply return the corresponding member.
my attempt:
TestScore::TestScore(string name, int score) :
studentName(name) , studentScore(score)
{
}
TestScore::GetName() const
{
return studentName;
}
TestScore::GetScore() const
{
Return studentScore;
}
3. Write the implementation file for the IDScore class in Exercise 1. The constructor just assigns its parameters to the private data members, and the observer simply returns the corresponding member.
my attempt:
TestScore::TestScore(int studID, int studScore, string studName) : studentIDNumber(studID)
{
}
TestScore::GetIDNumber() const
{
return studentIDNumber;
}