i made a program in dev c++ to calculate salary of regular based employee and hourly based employee but when i compile the program i got some errors. i want to inherit person class in both re and hbe class but the problem is that the function definitions for input();calsalary() and display() are different for the child classes.
error- no `void re::input()' member function declared in class `re'
same for other member functions also
Code:#include<iostream> #include<conio.h> using namespace std; class person { protected: char ch[20]; public: void input(); float calsalary(); void display(); }; class re:public person { int empid; float basic,da,hra,pf; }; class hbe:public person { int empid,hpm; float pph; }; void re::input() { cout<<"\n Name = "; cin>>ch; cout<<"\n Emp ID = "; cin>>empid; cout<<"\n Basic pay = "; cin>>basic; cout<<"\n DA = "; cin>>da; cout<<"\n HRA = "; cin>>hra; cout<<"\n PF = "; cin>>pf; } float re::calsalary() { return(basic+da+hra+pf); } void re::display() { cout<<"\n Name = "<<ch; cout<<"\n Emp ID = "<<empid; cout<<"\n DA = "<<da; cout<<"\n HRA = "<<hra; cout<<"\n PF = "<<pf; cout<<"\n Net Salary = "<<calsalary(); } void hbe::input() { cout<<"\n Name = "; cin>>ch; cout<<"\n Emp ID = "; cin>>empid; cout<<"\n Pay per hour = "; cin>>pph; cout<<"\n Hours per month = "; cin>>hpm; } float hbe::calsalary() { return(pph*hpm); } void hbe::display() { cout<<"\n Name = "<<ch; cout<<"\n Emp ID = "<<empid; cout<<"\n Hr per mon = "<<hpm; cout<<"\n Pay per Hr = "<<pph; cout<<"\n Net Salary = "<<calsalary(); } int main() { re o1; hbe o2; cout<<"\n\t\t Regular Employee \n"; o1.input(); o1.display(); cout<<"\n\t\t Hourly Based Employee \n"; o2.input(); o2.display(); getch(); return 0; }



LinkBack URL
About LinkBacks



