Jump to content
  • Advertisement

Archived

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

New and This

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

Can someone tell me what "this" is used to in VC++. If you look at the DirectX SDK sample game Donuts, "this" is used very often, but i am not quite sure what it means. Also, if you look at the source for Donuts, you will probably find a statement similar to this somewhere: new = (LPDBLNODE) LocalAlloc( LPTR, sizeof( DBLNODE ) ); How is that possible??? I thought new was used to allocate memory for objects, but here it is used as a pointer. After i saw this a statement like "return = (RECT*)&rc;" would not surprise me *S*. Any help is really appreciated.

Share this post


Link to post
Share on other sites
Advertisement
this is the pointer to the current object you''re in. When you''re writing your class, you can use this to get a pointer to yourself.

And for the new = (LPDBLNODE) LocalAlloc( LPTR, sizeof( DBLNODE ) );
You''re right! new is used for dynamic memory allocation, but in ++ only.
If you''re not using C++, but only simple C, the new is unknown and then it can be used as a normal variable.

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.

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

Sign me up!