what is "this", and why is "this" ? :)
Hi All !
I noticed MFC guys use this pointer to store some data there (in CString). Is it a valid technique ? what does "this" point to , apart from the usual "it points to the object" stuff ? :)
is there some allocated memory referenced by it, we can use ?
I suppose data members are lined up at the pointer, and function addresses perhaps ? No i am talking crap right ? :)
Best wishes to the whole forum!
Re: what is "this", and why is "this" ? :)
CString is a bit wacky. It's very efficient, it's just a bit strange.
There exists a struct (I don't know it's name), which hold the various details about a CString: Len, reference count, etc. It is a fixed size. Immedaitely after it in memory is the text of the string.
A CString object is just a pointer into the middle of that. It naturally points to the character date (so it works in printf statements), but if you substract a certain amount from the pointer, you get the other data.
So, any weirdness using "this" in CString is due to this bizare format. "this" has no meaning other than the usual "it points to the object" stuff.
Truth,
James
http://www.NJTheater.com
http://www.NovelTheory.com
I don't do it for the points (OK, maybe I do), but rating a post is a good way for me to know if I helped.
Re: what is "this", and why is "this" ? :)
but is it possible to allocate data at "this" location and store it safely ?
Re: what is "this", and why is "this" ? :)
I'll need to see an example of what you are trying...
Truth,
James
http://www.NJTheater.com
http://www.NovelTheory.com
I don't do it for the points (OK, maybe I do), but rating a post is a good way for me to know if I helped.