[ create a new paste ] login | about

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

C++, pasted on May 9:
#include <iostream>

class IA {
public:
   virtual void f()=0; 
};
class IB : public IA {
public:

};
class A : public IA {
public:
  void f() {
    std::cout << "f() called" << std::endl;
  }; 
};
 class B : public A, public IB {
public:
  void f() {A::f();}
};

int main(int argc, char **argv) {
  
 B b;
 IA &ia = static_cast<IB &>(b);
 ia.f();
 std::cout << "sizeof(B): " <<sizeof(b) << std::endl;

}


Output:
1
2
f() called
sizeof(B): 8


Create a new paste based on this one


Comments: