I have tried a couple different ways of assigning variables to this array. When I do it this way I get an error on the payroll[i] = h; that says "No viable overloaded '='
//
// main.cpp
// Week 7 Assignment 1
//
// Created by Adam Windsor on 10/1/14.
// Copyright (c) 2014 Adam Windsor. All rights reserved.
//
#include <iostream>
#include <iomanip>
#include "payroll.h"
usingnamespace std;
constint SIZE = 7;
int main()
{
Payroll payroll[SIZE];
for (int i = 0; i<1; i++)
{
int h;
double r;
cout << "Please enter number of hours for employee " << i + 1 << endl;
cin >> h;
payroll[i] = h;
}
//cout << Payroll::getHours();
return 0;
}
I have also tried this. There is no error message but the variable 'h' is not assigned to the setHours member.
1 2 3 4 5 6 7 8 9 10 11 12 13
Payroll payroll[SIZE];
for (int i = 0; i<1; i++)
{
double h;
double r;
cout << "Please enter number of hours for employee " << i + 1 << endl;
cin >> h;
payroll[i].setHours(h);
}
Doing it this way payroll[i].setHours(h); is the correct way in doing so the reason why it doesn't work is there is a problem within your setHours() method.
1 2 3 4 5 6
void Payroll::setHours(double h)
{
// You are assigning Hours to h when it should be the otherway around.
// For example it should be Hours = h;
h=Hours;
}
The same goes for your setPay() method, you need to swap those around also.