View Poll Results: Why is Functions within Functions not allowed in C or C++ ?
- 1. You may not vote on this poll
Other languages support and because func within func is messy coding like GOTO label ??
Thread: Functions In Structures !?!
10-09-04, 15:55 #1Registered User
- Join Date
- Oct 2004
Unanswered: Functions In Structures !?!
1)How do u access functions that are within structures and make them return a value to not the main but to another (void) function ? ( Dunno if qn is phrase is correctly ??)
2)Below is an excerpt from a vending machine program in C++ but how do u convert to C without using :the scope resolution operator) ? or Is the below program unable to be converted to C...
BTW: some reasoning of the program may be wrong especially the data inside Convert_to_Denom as this part is wat me coded moiself...^^;;
Mani Thks for all who readin tis
struct coins ten, twenty, fifty;
void Convert_to_Denom(struct machine *m);
struct machine *mac;
void Convert_to_Denom(struct machine *m)
void coins::setDenom(int D)
denomination = D;
11-18-04, 22:03 #2Registered User
- Join Date
- Nov 2004
Functions within structures and Convert C++ to C
Well as for question 1 - Huh? Do you mean in C or C++? In either you can use a pointer to a function as a parmeter of another function so the value is passed in the stack an not held in storage within the scope on the main program body.
Question 2 - You mostly have the code in C format already. All you need to do is not declare the functions inside of a class (you declared it as a structure).
You need to study. We do do not do your homework here. BTW please attempt proper grammatical syntax in you corresponence. Sloppy language promotes sloppy code.