Jump to content
  • Advertisement

Archived

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

Wavarian

Requesting quick help on class pointers..

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

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!