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 :
#include <iostream>
using namespace std;
class Person{
public:
Person( string nam, string day);
string get_name()const;
string get_date()const;
void print()const;
private:
string name;
string date;
};
Person::Person( string nam,string day){
name= nam;
date= day;
}
string Person::get_name() const
{
return name;
}
string Person::get_date() const
{
return date;
}
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;
}
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 :idea: