I am learning c++ and have a construct error that I can't figure out. says no default constructor where it says Employees* Employee = new Employees[y];
It is very likely that it is a simple mistake. Code:
#include <string>
using namespace std;
class Employees {
private:
int age;
int Year_pay;
string Name;
public:
Employees(string N, int a, int p) {
setName(N);
setAge(a);
setpay(p);
}
int getAge() {
return age;
}
void setAge(int ag) {
age = ag;
}
string getName() {
return Name;
}
void setName(string Na) {
Name = Na;
}
int getPay() {
return Year_pay;
}
void setpay(int Pa) {
Year_pay = Pa;
}
};
int main()
{
int y = 5;
Employees* Employee = new Employees[y];
for (int i = 0; i < y; ++i) {
string Tname = "";
cout << "What is Employee Name?";
cin >> Tname;
int Tage = 0;
cout << "What is Employee age?";
cin >> Tage;
int Tpay = 0;
cout << "What is Employee yearly pay?";
cin >> Tage;
Employee[i](Tname, Tage, Tpay);
}
cout << Employee[6].getAge()
return 0;
}