#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
struct PayInfo
{
int hours; // Hours Worked
double payRate; // Hourly Pay Rate
};
struct PayRoll
{
int empNumber; // Employee number
string name; // Employee's name
double grossPay; // Gross Pay
PayInfo pay;
PayRoll (PayInfo& info, int num = 0, string Name = "", double gPay = 0.00)
{
empNumber = num;
name = Name;
grossPay = gPay;
pay.hours = info.hours;
pay.payRate = info.payRate;
}
};
int main()
{
PayRoll employee; // employee is a PayRoll structure.
// Get the employee's number.
cout << "Enter the employee's number: ";
cin >> employee.empNumber;
// Get the employee's name.
cout << "Enter the employee's name: ";
cin.ignore(); // To skip the '\n' character left in the input buffer
getline(cin, employee.name);
// Get the hours worked by the employee.
cout << "How many hours did the employee work? ";
cin >> employee.pay.hours;
// Get the employee's hourly pay rate.
cout << "What is the employee's hourly payRate? ";
cin >> employee.pay.payRate;
No, the only constructor you have is PayRoll (PayInfo& info, int num = 0, string Name = "", double gPay = 0.00)
which needs at least one argument (a PayRoll&).
A default constructor needs to be callable with no arguments, so you need either PayRoll() or something along the lines of PayRoll(/* all optional arguments */).