my problem is when I run this code it skips the line of getline(cin,emp_name)
for some reason and print nothing in showdata(). but it works for the emp_job aren't they the same thing?
thank you in advance.
#include <iostream>
#include <string>
using namespace std;
class emp {
private:
long int emp_number;
string emp_name;
string emp_job;
float emp_bonus;
public:
void getdata() {
cout << " enter your id ";
cin >> emp_number;
cout << " enter your name ";
getline(cin , emp_name);
cout << " enter your job tital " ;
getline(cin , emp_job);
}
void showdata() {
cout << " you id is " << emp_number << endl;
cout << " your name is " << emp_name << endl;
cout << " your job is " << emp_job << endl;
}
};
int main() {
emp one;
one.getdata();
one.showdata();
return 0;
}