下面的代码是我试图输出一个语句的代码,该语句将询问用户输入然后移动到请求另一个用户输入的下一个输出。
我已将代码缩小到我有疑问的部分,目前代码将显示如下:
输入名字:
输入中间名:
输入姓氏:
(然后用户可以输入)
员工类型((S)警告/(H)我们:
PayRate \ t \ t \ tt:t
输入本周工作时数:
然而,我需要发生的是它要求输入然后允许用户在显示下一个输出语句之前输入,如:
输入名字:(用户输入)
输入中间名:(用户输入)
等...
我在网上搜索过,但我找不到符合这个需求的东西。我全都是为了学习,感谢任何帮助。
ostream& operator<< (ostream& output, Person& PerObj) {
output << "Enter the first name : " << endl;
output << "Enter the middle name: " << endl;
output << "Enter the last name : " << endl;
return output;
}
istream& operator>> (istream& input, Person& PerObj) {
input >> PerObj.FirstName;
input >> PerObj.MiddleName;
input >> PerObj.LastName;
return input;
}
// Employee -------------
ostream& operator<< (ostream& output, Employee& EmpObj) {
Person PersonObj;
cout << PersonObj;
output << "Employee type ((S)alaried / (H)ourly: " << endl;
output << "PayRate \t\t\t : " << endl;
output << "Enter the hours worked for this week: " << endl;
return output;
}
istream& operator>> (istream& input, Employee& EmpObj) {
return input;
}
Person::Person() {
}
Employee::Employee() {
}
void main()
{
Employee e;
cout << endl << e;
system("pause");
system("cls");
Student s;
cout << endl << s;
system("pause");
system("cls");
}