Hello
I can't understand why 1st cin for Enter Name is skipped out of 3 cin statements in getData function in Teachers class other 2 cin statements are accepting input- Here is code -
#include <iostream.h>
#include <stdio.h>
#include <conio.h>
#include <string.h>
class Teachers
{
private:
char staff[20];
char post[20];
char address[30];
public:
void getData()
{
cout<<"Enter Name";
cin.getline(staff,20);
cout<<"Enter Post";
cin.getline(post,20);
cout<<"Enter Address";
cin.getline(address,30);
}
};
class Regular:public Teachers
{
private:
int HRA, DA, Basic, cHRA, cDA, Gross, Net;
public:
void getAllData()
{
getData();
cout<<"Enter Basic Pay";
cin>>Basic;
cout<<"Enter HRA";
cin>>HRA;
cout<<"Enter DA";
cin>>DA;
}
};
class Contractual:public Teachers
{
private:
int Wages;
int WorkingDay;
int CCL;
int ML;
int cWages;
public:
void getAllData()
{
getData();
cout<<"Enter Daily wages";
cin>>Wages;
cout<<"Enter Working Days";
cin>>WorkingDay;
}
};
int main()
{
Regular reg;
Contractual con;
char cata='R';
clrscr();
cout<<"Enter the catagory for calculation ";
cin>>cata;
if(cata=='R' || cata=='r')
{
reg.getAllData();
}
else
{
con.getAllData();
}
return 0;
}
Please show me the way
Regards