PDA

View Full Version : How can we check the size of a pointer?



learning_qt
12th January 2009, 12:48
I hope to check the allocated memory for one pointer with QT, but which function can we use?

like this:


ClassA *a = new ClassA();
int size = sizeof(a)

Lykurg
12th January 2009, 13:23
Hi,


int size = sizeof(*a);

is your friend and normal C++.

Lykurg

jpn
12th January 2009, 18:19
There's also QT_POINTER_SIZE.

aamer4yu
13th January 2009, 04:58
Size of pointer is usually word size. They just hold addresses, remember ?
The size of class is size of object. sizeof(*a), in ur case