fork(1) download
  1. #include <iostream>
  2.  
  3. class Base
  4. {
  5. public:
  6.  
  7. typedef int func_t (int x);
  8.  
  9. virtual func_t function = 0;
  10.  
  11. virtual int function2(int x) = 0;
  12. };
  13.  
  14. class Derived : public Base
  15. {
  16. public:
  17. func_t function;
  18. int function2 (int x);
  19. };
  20.  
  21. int Derived::function(int x)
  22. {
  23. return x;
  24. }
  25.  
  26. int Derived::function2(int x)
  27. {
  28. return x;
  29. }
  30.  
  31. int main()
  32. {
  33. Base * theClass = new Derived();
  34.  
  35. std::cout << theClass->function(1) << std::endl;
  36. std::cout << theClass->function2(2) << std::endl;
  37.  
  38. delete theClass;
  39.  
  40. return 0;
  41. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
1
2