I am trying to write a program that will demonstrate the use of functions with a structure. I know a lot of students try to get quick answers, I want to learn, but I am stuck, and could really use some help.
I keep getting the following error: C2448: 'salary' : function-style initializer appears to be a function definition
I am only trying to get one function to work in the menue (the 1st one) and then I will move on. Baby steps :) I have declared the function before my int main statement. The function definitions are just a simple input/output statement for hours and wage.
I just can't see where I am going wrong. Can someone point me in the right direction please. I have included the code below. I know it is pretty ugly. Bare with me, I am learning, and like I say this is a rough draft, just tring to get the menu functions to work. I think, hope I am close. I understand functions, but combining them with structures is messing me up. Do I use the void command when calling the function or would I use float instead since the variables are all floats. Sorry for all the questions. I really want to learn, anyh help is greatly appreciated.
Any help is greatly appreciated.
///////////////////////////////////////////////////////////////////////
#include <iomanip> // used for setprecison and ios flags
#include <iostream>
using namespace std;
#include "process.h"
// Structure
struct pay
{
float rop, hours;
float wage, regularwage, noot; //noot represents no overtime
};
void salary(pay);
int main()
{
int payroll;
char ch;
pay pay1;
cout << setiosflags(ios::fixed) // show value as fixed decimal point
<< setiosflags(ios::showpoint) // show decimal point
<< setprecision(2); // show 2 decimals
//////////////////////////////////////////////////////////////////////////////////////////
//Menu
cout <<" Wayne Industries 2000 Payroll Sytem \n ";
cout <<"Please select an option by entering a number from the menu below (1-5). \n";
cout <<" 1. Enter payroll information \n";
cout <<" 2. Update payroll information \n";
cout <<" 3. Calculate gross wages \n";
cout <<" 4. Print salary information \n";
cout <<" 5. Exit the payroll program \n";
cin >> payroll;
//////////////////////////////////////////////////////////////////////////////////////////
//Switch Functions
switch(payroll)
{
case 1:
salary(pay1);
break;
case 2:
cout << "2. You enter the payroll info here";
break;
case 3:
cout << "3. You enter the payroll info here";
break;
case 4:
cout << "4. You enter the payroll info here";
break;
case 5:
cout << "5. You enter the payroll info here";
break;
}
//////////////////////////////////////////////////////////////////////////////////////////
//Function Statements
void salary(pay1)
{
cout << "Enter the hourly wage of the worker: $";
cin >> pay1.rop;
cout << "Enter the number of hours worked this week: ";
cin >> pay1.hours;
}
}
<< moderator edit: added [co[u][/u]de][/co[u][/u]de]
tags >>