Well it is an assignment question here is the question :
Implement a base class Person. Derive classes Student and Instructor from Person. A person has
a name and a birthday. A student has a major, and an instructor has a salary. Write the class
definitions, the constructors, and the member functions print() for all classes.
this is what i have got so far any kind of help will be good :
cout<<" Mr/Mrs."<<name<<" was born on "<<date<<"\n";}
int main (){
string nam1;
string dat1;
cout<< " Please enter the name of student \n";
cin>>nam1;
cout<< " Please enter the date of birth in the format dd/mm/yyyy \n";
cin>>dat1;
Person(nam1,dat1);
return0;
}
Well i have managed to get the base class person but it gives error can someone help me out with whats wrong and how to implement the other required derived class student and instructor
Last edited by Ancient Dragon; Apr 11th, 2007 at 8:45 am. Reason: correct code tags and reformat code so it can be read
First learn how to properly format your programs. I helped you out this time by doing it for you just so you can see how it should be done. There is absolutely nothing wrong with being generous with spaces and line feeds -- makes your program a lot easier to read.
>> it gives error
what error? I suspect it might be because you did not include <string> header file.
>>and how to implement the other required derived class student and instructor
here is how to declare Student. Other derived classes are the same format.
void Person:: print()const{
cout<<" Mr/Mrs."<<name<<" was born on "<<date<<"\n";}
int main (){
string nam1;string dat1;
cout<< " Please enter the name of student \n";
cin>>nam1;
cout<< " Please enter the date of birth in the format dd/mm/yyyy \n";
cin>>dat1;
Person(nam1,dat1);
return 0;
}
Last edited by raj157; Apr 11th, 2007 at 12:43 pm.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.