fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Animal {
  5. public:
  6. virtual int getType() = 0; // purely virtual method
  7. };
  8.  
  9. class Cat : public Animal {
  10. public:
  11. int getType() {
  12. return 42;
  13. }
  14. };
  15.  
  16. int main() {
  17. Animal * array[10];
  18. array[0] = new Cat();
  19. std::cout << array[0]->getType() << std::endl;
  20. return 0;
  21. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
42