Jump to content
  • Advertisement

Archived

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

sakky

pointer pointer

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

Advertisement
The example is not usefull in any way... but shows
how you can use a double pointer.

int iMaxElements=32;
int** ppIntPointerList;

ppIntPointerList=new int*[iMaxElements];

for (int i=0;i{
ppIntPointerList=new int;
*ppIntPointerList[i]=i;
}

Share this post


Link to post
Share on other sites

vector intPtrVec;

intPtrVec.erase( &intPtrVec[1] ); <-- &intPtrVec[1] is the address of a pointer; that is; a pointer to a pointer.

(It's killing my braces. :/ 'Vector(lessthen)int*(greaterthen) intPtrVec

You use pointers to pointers when you need to manipulate the pointer like a regular value, or need it to be treated as the value rather then the address of one.

Also; that code causes a memory leak. The pointer to the int is erased, but the int itself is never deleted.


[edited by - deyja on August 13, 2002 9:56:27 AM]

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!