How can I implement polymorphism in this program?
Apr 6, 2011 at 10:19am UTC
Hi, i've got a prgram for a college system which allows a user to determine the overall grades for a student. What I want to do is add polymorphism to this program, but im sure how I could? the program uses a base class and a derived class.
Heres the code for main:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
#include "HNDStudent.h"
#include "NatdipStudent.h"
int main(int argc, char *argv[])
{
string sname, sQT,g;
double sID;
char si;
int sQL,sY;
HNDstudent s2009("x" , 'x' , 000, 0, "x" , 0, "incomplete" );
s2009.Set_surname(sname);
s2009.Set_initial(si);
s2009.Set_ID(sID);
s2009.Set_level(sQL);
s2009.Set_qual_title(sQT);
s2009.Set_year(sY);
s2009.Set_grade(g);
cout<<s2009.Get_surname()<<endl; //inherited functions
cout<<s2009.Get_initial()<<endl;;
cout<<s2009.Get_ID()<<endl;;
cout<<s2009.Get_level()<<endl;;
cout<<s2009.Get_qual_title()<<endl;;
cout<<s2009.Get_year()<<endl;
cout<<s2009.Get_grade()<<endl;
system("PAUSE" );
return EXIT_SUCCESS;
}
Topic archived. No new replies allowed.