hi ppl,
im havin a problem with declaration of functions, its givin me errors on the functions i made.

// empleados.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
using std::basic_iostream;


char menu (char);
void ingresar_legajo_hijos (int &, int &);
void ingresar_horasTrabajadas_valorHora (int &, float &);
void mostrar_datosEmpleado ();



int main(int argc, char* argv[])
{

	using namespace std; 

	char empleado = 0; 
	float sueldo = 0, valor_hora = 0, total; 
	float ventas_a_comision = 0, precio_producto_a_destajo; 
	int hora = 0, horas_extras = 0; 
	int cantidad_vendida; 
	int totales_empleados = 0; 
	int antiguedad; 
	int legajo, hijos; 
	float a_pagar = 0, sueldo_total = 0; 
     
	 
	menu (empleado);
     
	cout << " Se ingresa un maximo de 100 empleados!" << "\n" << "\n"; 
     
	while ((empleado != '5') && (totales_empleados < 100)) 
	{
		switch (empleado) 
		{
			case '1': // GERENTES! 
				ingresar_legajo_hijos (legajo, hijos);
				ingresar_horasTrabajadas_valorHora (hora, valor_hora);
                   
				total = ((hora * valor_hora)/4); // por semana 
                   
				cout << " Ingrese la antiguedad: "; 
				cin >> antiguedad;
				cout << "\n"; 
               
				if ((antiguedad >= 2) && (antiguedad <= 4)) 
					a_pagar = (total*0.2) + total;
				else if ((antiguedad >= 5) && (antiguedad <= 8)) 
					a_pagar = (total*0.4) + total;
				else if ((antiguedad >= 9) && (antiguedad <= 12)) 
					a_pagar = (total*0.6) + total;
				else if ((antiguedad > 13)) 
                    a_pagar = (total*0.8) + total;
               
				if (hijos > 3) 
					sueldo_total = (a_pagar * 1.5) + a_pagar;
                    cout << " El legajo del empleado es: " << legajo; 
                    cout << " Tiene " << hijos << " hijos"; 
                    cout << " El sueldo que va a cobrar es de: " << total << " Pesos aproximadamente x semana"; 
                    cout << " El total a cobrar por mes es de " << sueldo_total; 
			break; 


			case '2': // OBREROS! 
				ingresar_datos (legajo, hijos, hora, valor_hora); 
                    
				if (hora < 40) 
                   cout << " Se le pagan $" << (hora * valor_hora); 
				else 
				{
					horas_extras = hora - 40;
					total = horas_extras * (valor_hora * 1.5) + (hora * valor_hora);
				}
            
				cout << " Ingrese la antiguedad: "; 
				cin >> antiguedad;
                         
				if ((antiguedad >= 2) && (antiguedad <= 4)) 
					a_pagar = (total*0.2) + total;
				else if ((antiguedad >= 5) && (antiguedad <= 8)) 
					a_pagar = (total*0.4) + total;
				else if ((antiguedad >= 9) && (antiguedad <= 12)) 
					a_pagar = (total*0.6) + total;
				else if ((antiguedad > 13)) 
					a_pagar = (total*0.8) + total;
                    
				
				if (hijos > 3) 
					sueldo_total = (a_pagar * 1.5) + a_pagar;
					cout << " El legajo del empleado es: " << legajo << "\n"; 
					cout << " Tiene " << hijos << " hijos" << "\n"; 
					cout << " El sueldo que va a cobrar es de: " << (total / 4) << " Pesos aproximadamente x semana" << "\n" << "\n"; 
					cout << " El total a cobrar por mes es de " << sueldo_total << "\n"; 
			break; 


			case '3': //POR COMISION! 
				ingresar_legajo_hijos (legajo, hijos);

				cout << " Se le va a pagar un fijo de 500 $ mensuales" << "\n"; 
				cout << " Ingrese la cantidad de ventas hechas: "; 
				cin >> ventas_a_comision;

				total = (500 + (((ventas_a_comision * 5.7)/100)*4))/4;

				cout << " Ingrese la antiguedad: "; 
				cin >> antiguedad;
                   
				if ((antiguedad >= 2) && (antiguedad <= 4)) 
					a_pagar = (total*0.2) + total;
				else if ((antiguedad >= 5) && (antiguedad <= 8)) 
					a_pagar = (total*0.4) + total;
				else if ((antiguedad >= 9) && (antiguedad <= 12)) 
					a_pagar = (total*0.6) + total;
				else if ((antiguedad > 13)) 
					a_pagar = (total*0.8) + total;
                   
				if (hijos > 3) 
					sueldo_total = (a_pagar * 1.5) + a_pagar;
					cout << " El legajo del empleado es: " << legajo << "\n"; 
					cout << " Tiene " << hijos << " hijos" << "\n"; 
					cout << " Va a cobrar: " << total << " Pesos aproximadamente x semana" << "\n" << "\n"; 
					cout << " El total a cobrar por mes es de " << sueldo_total << "\n"; 
			break; 
          
		  
			case '4': // A DESTAJO! 
				ingresar_legajo_hijos (legajo, hijos);

				cout << " Ingrese el precio del producto: "; 
				cin >> precio_producto_a_destajo;
				cout << "\n" << " Ingrese la cantidad de cosas que vendio: "; 
				cin >> cantidad_vendida; 
               
				total = (precio_producto_a_destajo * cantidad_vendida)/4;

				cout << " Ingrese la antiguedad: "; 
				cin >> antiguedad;
              
				if ((antiguedad >= 2) && (antiguedad <= 4)) 
					a_pagar = (total*0.2) + total;
				else if ((antiguedad >= 5) && (antiguedad <= 8)) 
					a_pagar = (total*0.4) + total;
				else if ((antiguedad >= 9) && (antiguedad <= 12)) 
					a_pagar = (total*0.6) + total;
				else if ((antiguedad > 13)) 
					a_pagar = (total*0.8) + total;
              
				if (hijos > 3) 
					mostrar_datosEmpleado ();
			break; 
		}

		menu(empleado);
		totales_empleados ++;

		

	   system ("PAUSE");
       return 0; 
}



char menu (char &ingresar)
{
	using namespace std;
	cout << " Ingrese el codigo del empleado: " << "\n"; 
	cout << " 1 - GERENTE " << "\n"; 
	cout << " 2 - OBREROS" << "\n"; 
	cout << " 3 - POR COMISON" << "\n"; 
	cout << " 4 - A DESTAJO" << "\n"; 
	cout << " 5 - salir" << "\n" ; 
	cin >> ingresar;
	cout << "\n" << "\n";

	return ingresar;
}



void ingresar_legajo_hijos (int &legajo, int &hijo);
{
	using namespace std;

	int hijo;

	cout << " Ingrese Legajo: "; 
	cin >> legajo;

	cout << " Cuantos hijos tiene?? "; 
	cin >> hijo;
}



void ingresar_horasTrabajadas_valorHora ()
{
	using namespace std;

	cout << " Ingrese cantidad de horas trabajadas: "; 
	cin >> horas;
	cout << "\n"; 

	cout << " De cuanto es el valor de la hora?? " ; 
	cin >> valor_hora;
	cout << "\n"; 
}



void mostrar_datosEmpleado (int &legajo, int &hijos, float &total, float &sueldo_total)
{
	using namespace std;

	cout << " El legajo del empleado es: " << legajo; 
	cout << " Tiene " << hijos << " hijos"; 
	cout << " El sueldo que va a cobrar es de: " << total << " Pesos aproximadamente x semana"; 
	cout << " El total a cobrar por mes es de " << sueldo_total; 
}

the errors its givin me r:

--------------------Configuration: empleados - Win32 Debug--------------------
Compiling...
empleados.cpp
C:\Documents and Settings\pm11218\empleados\empleados.cpp(69) : error C2065: 'ingresar_datos' : undeclared identifier
C:\Documents and Settings\pm11218\empleados\empleados.cpp(170) : error C2601: 'menu' : local function definitions are illegal
C:\Documents and Settings\pm11218\empleados\empleados.cpp(202) : error C2601: 'ingresar_horasTrabajadas_valorHora' : local function definitions are illegal
C:\Documents and Settings\pm11218\empleados\empleados.cpp(217) : error C2601: 'mostrar_datosEmpleado' : local function definitions are illegal
C:\Documents and Settings\pm11218\empleados\empleados.cpp(225) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

empleados.exe - 5 error(s), 0 warning(s)

tnks!!

byeee

Recommended Answers

All 3 Replies

The first error means that the function ingresar_datos has never been declared - if you look through the code, there is indeed no function with that name.
The rest of the errors are because the function prototype is slightly different than the function definition. For example, for menu you have the following as the prototype:

char menu (char);

But the following in the actual definition:

char menu (char &ingresar)

The function declaration should be identical to the function definition exept that you do not need to put a semi colon after the function definition. Another easier way to do it is to put the main at the bottom of the code. Here, you do not need to declare the functions you just define them..something like this..

int function_one (int a, int b)
{
      //data
}

char function_two(char c)
{
      //data
}

int main()
{
    //your program

  return 0;
}

thanks joshmo!!!
that worked out perfectly!

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.