Search code examples
c++sizeofabstract

Size of abstract class


How can I find the size of an abstract class?

class A
{
    virtual void PureVirtualFunction() = 0;
};

Since this is an abstract class, I can't create objects of this class. How will I be able to find the size of the abstract class A using the 'sizeof' operator?


Solution

  • You can use the sizeof operator:

    int a_size = sizeof(A);