Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include"Problem3.h"
- Employee::Employee(std::string x, std::string y, int z)
- {
- firstName = x;
- lastName = y;
- pay = z;
- }
- Employee::Employee()
- {
- firstName = "John";
- lastName = "Smith";
- pay = 40000;
- }
- void Employee::setInfo(std::string x, std::string y, int z)
- {
- firstName = x;
- lastName = y;
- pay = z;
- }
- void Employee::getInfo()
- {
- std::cout << firstName << " " << lastName << " (" << pay << ")" << std::endl;
- }
- void EmployeeAdd(Employee * x, int n);
- void EmployeePrint(Employee * x, int n);
- int main()
- {
- int numEmployees = -1;
- while (numEmployees < 1)
- {
- std::cout << "Number of Employees: ";
- std::cin >> numEmployees;
- }
- Employee * employees = new Employee[numEmployees];
- EmployeeAdd(employees, numEmployees);
- EmployeePrint(employees, numEmployees);
- system("pause");
- return 0;
- }
- void EmployeeAdd(Employee * x, int n)
- {
- for (int i = 0; i < n; i++)
- {
- std::string firstname, lastname;
- int pay;
- std::cout << "Employee " << i + 1 << std::endl;
- std::cout << "First Name: ";
- std::cin >> firstname;
- std::cout << "Last Name: ";
- std::cin >> lastname;
- std::cout << "Pay: ";
- std::cin >> pay;
- x[i].setInfo(firstname, lastname, pay);
- }
- }
- void EmployeePrint(Employee * x, int n)
- {
- std::cout << "Employees: " << std::endl << std::endl;
- for (int i = 0; i < n; i++)
- {
- x[i].getInfo();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement