[ create a new paste ] login | about

Link: http://codepad.org/HUlLB4Uq    [ raw code | output | fork ]

C++, pasted on Oct 12:
#include <iostream>

class Bar
{
    size_t len_;
public:
    Bar(size_t len) : len_(len) {std::cout << len << '\n';}
};

class Foo : virtual public Bar //virtual inheritance
{    
    size_t foo_bigger_than_bar;
public:
    Foo() : Bar(sizeof(Foo)) { }
};

class Derived2: public Foo
{    
    size_t derived2_bigger_than_foo;
public:
    Derived2() : Bar(sizeof(Derived2)), Foo() { }
};

int main() {
    Foo f;
    std::cout << '\n';
    Derived2 d;
}


Output:
1
2
3
12

16


Create a new paste based on this one


Comments: