fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Abstract {
  5. public:
  6. Abstract( void ) { cout << "Abstract constructor" << endl; };
  7. virtual ~Abstract( void ) {};
  8. void Foo( void ) { cout << "Abstract::Foo()"<< endl; };
  9. };
  10.  
  11. class Derived: public Abstract {
  12. public:
  13. Derived( void ): Abstract() { cout << "Derived constructor" << endl; };
  14. ~Derived( void ) {};
  15. void Foo( void ) { cout << "Derived::Foo()"<< endl; };
  16. };
  17.  
  18. void Bar( Derived obj ) {
  19. obj.Foo();
  20. }
  21.  
  22. int main(void) {
  23. Derived X;
  24. Bar ( X );
  25. return 0;
  26. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
Abstract constructor
Derived constructor
Derived::Foo()