Is it possible to assign the this pointer to a pointer variable outside the function's scope, and then use that pointer without problems?
Is it possible to assign the this pointer to a pointer variable outside the function's scope, and then use that pointer without problems?
That would take about 5 lines of code to test, and about 5 minutes of your time. Why don't you get some initiative?
Last edited by 7stud; 04-06-2003 at 05:21 PM.
>>That would take about 5 lines of code
I'd like to see that.
im not sure i totaly understand your question but maybe this will help.
'this' is a pointer to the object. so, if you want another pointer to have the same value as 'this' then...
now 'myNewThis' has the same value as the 'this' pointer used inside the object class when refering to object 'o'Code:object o; ...... object* myNewThis; myNewThis = &o;
the way you worded the question seems like you had something like this in mind...
once again myNewThis has the same value as 'this' for the object 'o' . this is the same result as the above example. and the myNewThis pointer should behave fine. it is no different than a regular pointer to an object.Code:object* object::getThis() { return this; } ........ object o; ..... object* myNewThis = o.getThis();
if what i just said had nothing to do with your question then just ignore me, lol. ive been writing a PHIL essay for the past 4 hours and im starting to lose sanity.
That was 6 lines, too bad.
Haha, just kidding.
If you ever need a hug, just ask.
Do parentheses count?
yes.Originally posted by 7stud
Do parentheses count?
actually it was 7, but i gave two examples of the same thing which implies an average of 4.5 lines. woohoo, i win!Originally posted by CheesyMoo
That was 6 lines, too bad.
Haha, just kidding.
actually the ' .... ' in my code would really make up a bunch more for a working test... ahhh well.
I found my problem...for some variables I forgot to assign this to the other pointer...
So I guess it's legal to do. Thanks for your time.
"woohoo, i win!"
Congratulations! You are the "Initiative Employee of the Month".