questions is: write a program using inheritance allow user to enter grades of his students 5~8 students as a base class and compute the sums for each students in derived class and compute the average of sums in another derived class
i created 3 classes in 1 header file and 1 cpp file how ever i cant seem to get the sum or the average to show up on execution time
ok let me see. First off, you have no need for subtype polymorphism in the main. Second GSum did not initialize sum, because at the getSum function you are adding the value of a[1][sum] to theSum, but the a[1][exam has no value].
I suggest adding this to Grades
1 2 3 4 5
public:
Grades(Grades &obj)//This is a copy constructor
{
*this=obj;//This instance of the class will take on the state of another
}
I haven't tested this, but it should work. However there are far more effective methods. In all honesty you also need to work on your naming conventions.