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 ??

    0 0%
  • IMMMpossible !

    0 0%
  • it's possible

    1 100.00%
  • Don't knoe

    0 0%
Results 1 to 2 of 2
  1. #1
    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{

    int denomination;

    void setDenom(int);
    int getDenom();

    struct machine{

    struct coins ten, twenty, fifty;

    void Convert_to_Denom(struct machine *m);

    struct machine *mac;

    return 0;

    void Convert_to_Denom(struct machine *m)


    void coins::setDenom(int D)
    denomination = D;

    int coins::getDenom()
    return denomination;

  2. #2
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts