Skip to main content
gamedev.net
🔒 Locked

pointer pointer

Started by sakky 2 replies 300+ views
Original Post
sakky
sakky
Can some one give me a good use for pinter pointers? Besides strings ( char * ).
Take back the internet with the most awsome browser around, FireFox
SabreMan
SabreMan
In which language?
Lazy303
Lazy303
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;
}

Deyja
Deyja

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]

Topic Locked

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

Sign in to reply to this topic.