You are here:

C++/Employee Payroll program


1. Visual C++ 6.0
2. input data from keyboard, calculate gross and net pay, print to screen and file.
3. using classes employee.h and payroll.h
4. I am an idiot! (just kidding) I dont know how to pass the info from one function to the next. I get errors like "C2660: 'PrintStubToScreen' : function does not take 0 parameters"

Passing info from one function to another function can be tricky. You could try using global variables, although this method is usually frowned upon. It really depends on where the functions are being called. If you have function 'A' and function 'B', both using the same variables, and being called from the 'main' portion of your program then the solution is relatively simple. Instead of doing a call by value, do a call by reference for any variables that you send to the function. That way the value of the variables that get modified in function 'A' will stay modified when the function is complete. Then when function 'B' is called, the variables that it uses will have the appropriate values.

However, if you have to call function 'B' from within function 'A', and 'B' requires variables that 'A' doesn't use, then it gets to be a bit more tricky. If function 'A' needs variables 1, 2, and 3, but function 'B' needs variables 3, 4, and 5, then you need to send the values of all the variables (1, 2, 3, 4, 5) to function 'A'. If you don't want to pass any values onto a function, then just don't give it any input parameters (occasionally I've done this). Doing this would solve the problem of "C2660: 'PrintStubToScreen' : function does not take 0 parameters". I hope this helps. If you need any clarification please let me know.

Best Of Luck,


All Answers

Answers by Expert:

Ask Experts


Alan F.


Having problems with any basic or intermediate parts of C++? I can answer those questions for you using simple English. I have been taking C++ in school for a couple years, so I still remember what it was like to be a beginner (especially with C++, which is a difficult language)!


I have a C++ web page that discuses the basics of C++. The address is:

©2016 All rights reserved.