Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Requesting quick help on class pointers..

This topic is 5904 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

Ok, here''s the scenario.. i have a class.. defined in the header file as: class TEMP { ...int variable; public: ...void setVariable(int &integer); ...int returnVariable(); } and in the cpp file: void TEMP::setVariable(int &integer) { ...variable = integer; } int TEMP::returnVariable() { ...return variable; } In my main code however, (in a loop) i wish to do something like this: int number = 1; int returnNumber; TEMP temp; temp.setVariable(number); +=Begin Loop=+ returnNumber = temp.returnVariable(); number++; +=End Loop=+ Simply (*snicker*) put, i need the class to store a pointer to a variable outside of the class, such that when i change the number, the class will point to the new number. I know the above code doesnt work, thats why im asking here. Any ideas as to how to do this? Arrrgh! Cheers.

Share this post

Link to post
Share on other sites

  • 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!