fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. class t_foo_base
  5. {
  6. public:
  7. t_foo_base(){};
  8. virtual ~t_foo_base(){}
  9. virtual std::string text( void ) const { return( "t_foo_base" ); };
  10. };
  11.  
  12.  
  13. class t_foo: public t_foo_base
  14. {
  15. public:
  16. t_foo(){};
  17. virtual std::string text( void ) const override { return( "t_foo" ); };
  18. };
  19.  
  20. std::string test_foo(t_foo_base p)
  21. {
  22. return p.text();
  23. }
  24.  
  25. int main()
  26. {
  27. t_foo_base* pBase = new t_foo;
  28. std::cout << test_foo(*pBase);
  29. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
t_foo_base