#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Posts
    0
    Rep Power
    0

    Question Help: Function Placement in C++


    I have these two voids that each call on the other. This is because one refreshes the screen and handles some other stuff, the other asks a question. The question one calls on the refresh after an answer is given and then the refresh ends up calling on the question again to get another answer.

    The problem is, when I go to compile, it acts as if the other void doesn't exist if it's below the current one. I am using the MinGW port of GCC for Windows.

    Is there a compiler option or something to fix this? Am I just not writing my code right?

    Note: I am a new to C++ but not to programming.
  2. #2
  3. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    792
    Are you declaring both of these functions in a header file?
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Posts
    0
    Rep Power
    0
    Ah, nope. So I would just use something like "void VoidName();" in an .h file and include it? I knew I should have been able to find it myself if only I knew what I was looking for :).

    Thanks
  6. #4
  7. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    792
    Originally posted by wesd
    Ah, nope. So I would just use something like "void VoidName();" in an .h file and include it? I knew I should have been able to find it myself if only I knew what I was looking for :).

    Thanks
    Yep, that should do it for you.
  8. #5
  9. Mobbing Gangster
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Sep 2001
    Location
    "Best City" 2002 and 2003- Melbourne, Australia
    Posts
    4,912
    Rep Power
    33
    You could do that or you could make a protoype of last void at the top. Something like

    #include <iostream.h>
    void showoptions(void);

    void main(void){
    cout<<"Select one of the options:\n";
    showoptions();
    }

    void showoption(){
    cout<<"1) do this and that\n 2) dont do this and that\n";
    //etc
    }

    Pardon me if something obvous is messed up - I'm more of a c guy rather then c++ :)
    And you know I mean that.
  10. #6
  11. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    792
    Originally posted by AlCapone
    Pardon me if something obvous is messed up - I'm more of a c guy rather then c++ :)
    That is why I said to use a header file instead of putting it in the same file. I am so use to using a header file with c. ;)

IMN logo majestic logo threadwatch logo seochat tools logo