Skip to main content
GameDev.net gamedev.net
🔒 Locked

Requesting quick help on class pointers..

Started by Wavarian Jul 27, 2002 at 12:24 AM 1 replies 250+ views
Original Post
Wavarian
Wavarian
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.
Wavarian
Wavarian
Oh, and i dont want to keep doing this in the loop either:

temp.setVariable(number)

Wavarian
Wavarian
WOOOOOOOOOOT! nevermind, got it

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.