fork download
  1. // bookcodeoopls.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include<iostream>
  6. using namespace std;
  7.  
  8.  
  9. class Employee
  10. {
  11. public:
  12. Employee(int empID, int pay);
  13. Employee(int empID);
  14. Employee();
  15.  
  16. void input();
  17. void output();
  18. int getSalary();
  19. int getID();
  20.  
  21. private:
  22. int empID;
  23. int pay;
  24. };
  25.  
  26.  
  27.  
  28. int main()
  29. {
  30. Employee myEmployee(2, 21), yourEmployee(5), ourEmployee;
  31. cout<<"Worker information:\n ";
  32. myEmployee.output();cout<<endl;
  33. yourEmployee.output();cout<<endl;
  34. ourEmployee.output();cout<<endl;
  35.  
  36. myEmployee = Employee(10, 31);
  37. cout<<"myEmployee is changed to the following values: \n ";
  38. myEmployee.output();cout<<endl;
  39.  
  40. system("pause");
  41.  
  42. return 0;
  43. }
  44.  
  45. Employee::Employee(int EmpID, int Pay):empID(EmpID), pay(Pay)
  46. {
  47. cout<<"The new worker has been created!!"<<endl;
  48. }
  49.  
  50. Employee::Employee(int EmpID): pay(1)
  51. {
  52. cout<<"The new worker has been created!!!"<<endl;
  53. }
  54. Employee::Employee():empID(1),pay(1)
  55. {
  56.  
  57. cout<<"The new worker has been created!!!!"<<endl;
  58.  
  59.  
  60.  
  61. }
  62. void Employee::output()
  63. {
  64.  
  65. input();
  66. cout<<"The employee ID number is: "<<empID<<" And their salary is: "<<pay<<endl;
  67. }
  68. int Employee::getSalary()
  69. {
  70. return pay;
  71. }
  72. int Employee::getID()
  73. {
  74. return empID;
  75. }
  76. void Employee::input()
  77. {
  78. cout<<"Please enter the value for the worker's employee ID"<<endl;
  79. cin>>empID;
  80. cout<<"And enter the value for the worker's pay: "<<endl;
  81. cin>>pay;
  82. }
  83.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:4:20: fatal error: stdafx.h: No such file or directory
 #include "stdafx.h"
                    ^
compilation terminated.
stdout
Standard output is empty