Guys please im confused, this is just a simple inheritance in c++ OOP. All i need is an input from a keyboard but nothing works. It works when i provide the data in the class object but not when i need an input...?
It will work when i try PTEmployee p1(1010,"shakespeare",300) & simplify code, but i need to test it with a keyboard input;
#include<iostream>
using namespace std;
class Employer
{
private:
int eId;
string eName;
public:
Employer (int id=1, string name="no name")
{
setEmpID(id);
setEmpName(name);
}
Employer(Employer &e)
{
eId=e.eId;
eName=e.eName;
}
void setEmpID(int id){eId=id;}
void setEmpName(string name){eName=name;}
int getEmpID(){return eId;}
string getEmpName(){return eName;}
};
class FTemployee:public Employer
{
private:
int salary;
public:
FTemployee (int id, string name, int sal):Employer(id, name)
{salary=sal;}
int getSal(){return salary;}
void setSal(int sal){salary=sal;}
};
class PTemployee:public Employer
{
private:
int wage;
public:
PTemployee (int id, string name, int wg):Employer(id, name)
{wage=wg;}
int getWage(){return wage;}
void setWage(int sw){wage=sw;}
};
int main()
{
FTemployee f1();
PTemployee p1();
//FT object
cout<<"What is your Employee ID: ";
cin>>f1.setEmpID();
cout<<"Name is your name please?: ";
cin>>f1.setEmpName()
cout<<"Please enter your Salary: ";
cin>>f1.setSal();
cout<<"Employee ID: "<<f1.getEmpID()<<endl;
cout<<"Name: "<<f1.getEmpName()<<endl;
cout<<"Salary: "<<f1.getSal()<<endl;
cout<<endl<<endl;
//PT object
cout<<"What is your Employee ID: "<<endl;
cin>>p1.setEmpID()<<endl;
cout<<"Name is your name please?: "<<endl;
cin>>p1.setEmpName()<<endl;
cout<<"Please enter your Wages: "<<endl;
cin>>p1.setWage()<<endl;
cout<<"Employee ID: "<<p1.getEmpID()<<endl;
cout<<"Name: "<<p1.getEmpName()<<endl;
cout<<"Wages: "<<p1.getWage()<<endl;
return 0;
}