Friday, January 25, 2013

VPTR


class MBase
{
public:
void f() const {};
~MBase(){}
};

if you try to check the size of this class, you can write something like:

MBase base;
cout<<sizeof(base);

OK the size is one byte. But upon changing it to virtual functions, the size of increase to four bytes. Check it out here:

http://www.cprogramming.com/tutorial/size_of_class_object.html

No comments:

Post a Comment