Archived

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

Bullmax

sizeof()

Recommended Posts

Does the keyword "sizeof()" takes processing time at runtime or it is a kind of macro that executes at compiliing time (prepocessor) ?
/* Bullmax */ ------------- Reality has many forms : good and evil, black and white, yin and yang.

Share this post


Link to post
Share on other sites
It''s an operator that is evaluated (to a constant) at compile time.


"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

Share this post


Link to post
Share on other sites
And with VOID.... LPVOID... ?



/* Bullmax */
-------------
Reality has many forms : good and evil, black and white, yin and yang.

Share this post


Link to post
Share on other sites
void isn''t a type (just a word for ''has no return value'') so sizeof(void) is an error.

sizeof(LPVOID) == sizeof(void*) will tell you the size in char''s of pointers on your platform (usually 4).

sizeof(polymorphic type) in a virtual member function will give you the sizeof the class of which that function is a member.

sizeof(*(ptr to polymorphic type)) gives you the size of the object which is represented by the type of the pointer specified, the same as the above.

Just add a virtual SizeOf() member function to polymorphic types if you need the functionality you require.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

Share this post


Link to post
Share on other sites
If you dereference the pointer of a polymorphic type, sizeof will return the sizeof the type of the pointer, not the what it is actually pointing to.

Share this post


Link to post
Share on other sites
Woah... 15 minutes and all these answers !

Thanks a lot guys !



/* Bullmax */
-------------
Reality has many forms : good and evil, black and white, yin and yang.

Share this post


Link to post
Share on other sites