In: Computer Science
Trying to create a Class of Employees that holds every Employee created from a class called Employee in c++
#include <iostream> #include <string> using namespace std; class Employee { private: string name; int idNumber; string department; string position; public: Employee(string name, int idNumber, string department, string position) : name(name), idNumber(idNumber), department(department), position(position) {} Employee(string name, int idNumber) : name(name), idNumber(idNumber), department(""), position("") {} Employee() : name(""), idNumber(0), department(""), position("") {} string getName() { return name; } void setName(string name) { this->name = name; } int getIdNumber() { return idNumber; } void setIdNumber(int idNumber) { this->idNumber = idNumber; } string getDepartment() { return department; } void setDepartment(string department) { this->department = department; } string getPosition() { return position; } void setPosition(string position) { this->position = position; } }; int main() { Employee employee1; employee1.setName("Cristiano ronaldo"); employee1.setIdNumber(7); employee1.setDepartment("IT"); employee1.setPosition("Engineer"); cout << "Name: " << employee1.getName() << "\n" << "ID Number: " << employee1.getIdNumber() << "\nDepartment: " << employee1.getDepartment() << "\nPosition" << employee1.getPosition() << endl << endl; return 0; }