ebco2.cpp

The following code example is taken from the book
C++ Templates - The Complete Guide, 2nd Edition
by David Vandevoorde, Nicolai M. Josuttis, and Douglas Gregor,
Addison-Wesley, 2017
© Copyright David Vandevoorde, Nicolai M. Josuttis, Douglas Gregor 2017


#include <iostream>

class Empty {
  using Int = int;  // type alias members don't make a class nonempty
};

class EmptyToo : public Empty {
};

class NonEmpty : public Empty, public EmptyToo {
};

int main()
{
  std::cout << "sizeof(Empty):    " << sizeof(Empty) << '\n';
  std::cout << "sizeof(EmptyToo): " << sizeof(EmptyToo) << '\n';
  std::cout << "sizeof(NonEmpty): " << sizeof(NonEmpty) << '\n';
}