Jump to content
  • Advertisement
Sign in to follow this  
bulletthebluesky

A question about functions

This topic is 3556 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a small question about c++ functions. When I recently started a large project, I noticed that whenever I wrote a function that referenced a function below it(physically in the code) it would throw an error. I think this is due to the compiler reading the code top to bottom. What can I do to work around this? See below for an example: (BTW my compiler is Visual C++ 2008 Express) Code: void Function1() { ... Function2(); } void Function2() { ... } End Code Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Promethium
Or even better, since your writing C++, use classes [smile]
Well, using classes wouldn't necessarily be 'better'; free functions have their place in C++, as does procedural programming in general. In any case, since we don't know what the OP is actually doing, we can't really say for certain that using classes would be a better choice.

Also, note that the issue in question applies to classes as well; the problem of declaration order is not specific to functions.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!