d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > C++ Help Calling Functions
12Next
Add Reply New Topic New Poll
Member
Posts: 4,734
Joined: Aug 20 2013
Gold: 0.00
Oct 21 2014 03:16pm
I need th make the following program:

Main program is used to declare 3 variables, a: the amount of pupils, c: their marks (1 per pupil to make it simple).
Secondary program would be used to calculate the average note of all the pupils listed (prom=c/a)
Then returns to main and shows value.

I don't remember how to call fuctions inside a main program. Can somebody help me please?

(use the names you want in the variables)
Member
Posts: 9,803
Joined: Jun 28 2005
Gold: 6.67
Oct 21 2014 03:37pm
Are you talking about different programs, or are you applying incorrect nomenclature to the subject?

If you mean normal functions, you call them like this:
Code
function(param1, param2);

Number of parameters is, of course, dependant on the function in question.
Member
Posts: 1,241
Joined: Jun 25 2011
Gold: Locked
Oct 22 2014 01:05am
Lol how do you actually do to forget that ?
Member
Posts: 13,893
Joined: Oct 21 2007
Gold: 1,244.00
Nov 7 2014 11:19pm
if it has to be 2 different files then I'm assuming one is going to be a file with a class in it. and the other with the main method

in the file with the main just create an instance of the class and then call function with "class object".function();
Member
Posts: 36,389
Joined: Jul 18 2008
Gold: 3,192.00
Nov 8 2014 05:08pm
Quote (feeble369 @ Nov 8 2014 12:19am)
if it has to be 2 different files then I'm assuming one is going to be a file with a class in it. and the other with the main method

in the file with the main just create an instance of the class and then call function with "class object".function();


If it's just a function there's no need to create a class for it.
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Nov 8 2014 05:28pm
Quote (Mastersam93 @ Nov 8 2014 06:08pm)
If it's just a function there's no need to create a class for it.


This is terrible advice, and promotes poor programming design.
Member
Posts: 36,389
Joined: Jul 18 2008
Gold: 3,192.00
Nov 8 2014 06:52pm
Quote (Minkomonster @ Nov 8 2014 06:28pm)
This is terrible advice, and promotes poor programming design.


oh ok.
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Nov 8 2014 07:04pm
I call functions by their pointers if you know what I mean.
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Nov 8 2014 07:57pm
Quote (AbDuCt @ Nov 8 2014 08:04pm)
I call functions by their panties if you know what I mean.


FTFY
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Nov 9 2014 12:39am
Quote (Eep @ Nov 8 2014 09:57pm)
FTFY


Code
void (*ptr)(char *str);
ptr = &bluePanties;
(*ptr)(argv[1]);


jajaja.

This post was edited by AbDuCt on Nov 9 2014 12:40am
Go Back To Programming & Development Topic List
12Next
Add Reply New Topic New Poll