Here is a snippet of my code as this is my final and would hate for anyone to find this and copy my final that I am working hard on. Everything else is working and is good. My problem is trying to get the following code to display.

void Employee::Calculate (Employee employee1, Employee employee2, Employee employee3)
{
    totalSalary = employee1.ePay + employee2.ePay + employee3.ePay;
    totalHours = employee1.eHours +  employee2.eHours + employee3.eHours;
    totalOvertimeHours = employee1.eOvertimeHours + employee2.eOvertimeHours + employee3.eOvertimeHours;

    cout << "*************************************************\n";
    cout << "**************EMPLOYEE SUMMARY DATA**************\n";
    cout << "*************************************************\n";
    cout << "**Total Employee Salaries .............." << totalSalary << "**\n";
    cout << "**Total Employee Hours .................." << totalHours << "**\n";
    cout << "**Total Overtime Hours  ................." << totalOvertimeHours << "**\n\n";
}

I have tried
Calculate();
Employee::Calculate;

I have looked at other examples that I could find and every code looks way different. How would I go about printing this part out?

Recommended Answers

All 6 Replies

How 'bout Employee::Calculate(parameters) ????

Employee::Calculate(totalOvertimeHours, totalSalary, totalHours);
Employee::Calculate(Employee employee1, Employee employee2, Employee employee3);
Employee::Calculate(totalOvertimeHours);
Employee::Calculate(Employee employee1);

When trying any of these, I get errors. (I am typing these in my main function)

Would posting all my code help?

Posting your errors will do more.

Also, using the same parameter types that you defined in the method would do wonders to reducing errors. Look up how to define parameters vs making the call. You're close, but making a silly mistake.

How about making an object call this method ? have you tried ?

try to use inline.. like this:

Inline Employee::Calculate(totalOvertimeHours, totalSalary, totalHours);
Inline Employee::Calculate(Employee employee1, Employee employee2, Employee employee3);
Inline Employee::Calculate(totalOvertimeHours);
Inline Employee::Calculate(Employee employee1);

@ usdblades - When you use a function do you include the data type of the pramater when you pass the variable?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.