d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Show Function
12Next
Add Reply New Topic New Poll
Member
Posts: 18,191
Joined: May 31 2010
Gold: 149.27
Oct 7 2014 03:48pm
Can you explain a "show function above the main"

Didnt want to clog up forms with easy questions I keep having..

// Details

I made a header file and .cpp file to go with that, then i made my program file,


its outputting gross pay and income tax pay

this is my main() code
Code
int main(){
weeklyEmp emp("Lucas", 40, 10 , 3, "M");
cout.width(9); cout << emp.grossPay();
cout.width(13); cout << emp.incomeTax() << endl;
emp.set_rate(11.50);
cout.width(9); cout << emp.grossPay();
cout.width(13); cout << emp.incomeTax() << endl;
emp.set_hours(42);
cout.width(9); cout << emp.grossPay();
cout.width(13); cout << emp.incomeTax() << endl;
}



and i have to make a show function above the main.

would that be making the output look like

Code
Gross Pay Income Tax
====== =======
xxxx zzzzz
xxxx zzzzz
xxxx zzzz



originally sent to blind, he told me to post it up

This post was edited by Trig on Oct 7 2014 03:49pm
Member
Posts: 6,562
Joined: Oct 29 2007
Gold: 4.00
Oct 7 2014 05:29pm
just make a void showFunction(); member of the weeklyemp class that will do your cout statements

if you want the function to be in main.cpp pass the instance of your class to the function and do the cout stuff

so like

Code
void showFunction(weeklyEmp employee) {
cout << employee.incomeTax() << endl;
}

int main() {
...
weeklyEmp emp("Lucas", 40, 10, 3, "M");

showFunction(emp);
}


This post was edited by Aimed_Shot on Oct 7 2014 05:49pm
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Oct 7 2014 06:00pm
Just don't name it showFunction. Just name it show. Otherwise you have a showFunction function. Silly.
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Oct 7 2014 06:01pm
Quote (Minkomonster @ Oct 7 2014 08:00pm)
Just don't name it showFunction. Just name it show. Otherwise you have a showFunction function. Silly.


I like to show functions while I show functions inside a function which shows itself.
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Oct 7 2014 06:13pm
Quote (AbDuCt @ Oct 7 2014 07:01pm)
I like to show functions while I show functions inside a function which shows itself.


I need to take a minute and reflect on how deep that statement was.
Member
Posts: 1,358
Joined: Dec 30 2012
Gold: 0.10
Oct 7 2014 11:06pm
Quote (AbDuCt @ Oct 7 2014 04:01pm)
I like to show functions while I show functions inside a function which shows itself.


Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Oct 7 2014 11:18pm
Quote (SelfTaught @ Oct 8 2014 01:06am)
http://cdn.meme.am/instances/500x/55106017.jpg


I love you.
Member
Posts: 6,562
Joined: Oct 29 2007
Gold: 4.00
Oct 8 2014 08:59am
guess I assumed he could come up with an appropriate name ;)
Member
Posts: 18,191
Joined: May 31 2010
Gold: 149.27
Oct 8 2014 09:30am
Haha the directions say not to use a void function i forgot to put that lol
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Oct 8 2014 11:22am
Quote (Trig @ Oct 8 2014 11:30am)
Haha the directions say not to use a void function i forgot to put that lol


Should drop that class if you can't figure out how to change a function return type.
Go Back To Programming & Development Topic List
12Next
Add Reply New Topic New Poll