I dont know wats wrong with my code but what am trying to do is for salary its an addition of DA and HRA. Here is my code.
#include <iostream.h>
class teacher{
private:
char name[20];
char subject[10];
float DA , HRA ;
float salary;
public:
void getdata();
void display();
int payrol();
};
int teacher::payrol(){
salary = DA + HRA ;
return 0;
};
void teacher::getdata(){
cout << "Specify your name. \n";
cin >> name ;
cout << "Specify your subject.\n";
cin >> subject ;
cout << "Specify your DA (Daily Allowence).\n";
cin >> DA ;
cout << "Specify your HRA (Home Rent Allowence).\n";
cin >> HRA;
};
void teacher::display(){
cout << " Name : " << name << endl ;
cout << " Subject : " << subject << endl ;
cout << " DA : " << DA << endl ;
cout << " HRA : " << HRA << endl ;
cout << " Salary : " << salary << endl ;
};
int main(){
teacher st;
st.getdata();
st.display();
cin.get();
cin.ignore();
return 0;
}
here every thing working fine except salary. I want salary as a sum of DA and HRA as i coded. But its not working :(