fork(1) download
  1. #include <iostream>
  2.  
  3. enum FooType : int
  4. {
  5. Crazy = 0,
  6. Cool
  7. };
  8.  
  9. enum BarType : int
  10. {
  11. Hello = Cool + 1,
  12. World
  13. };
  14.  
  15. class Foo
  16. {
  17. public:
  18. Foo(void)
  19. {
  20. }
  21.  
  22. ~Foo(void)
  23. {
  24. }
  25.  
  26. virtual int getType(void)
  27. {
  28. return Crazy;
  29. }
  30. };
  31.  
  32. class Bar : public Foo
  33. {
  34. public:
  35. Bar(void)
  36. {
  37. }
  38.  
  39. ~Bar(void)
  40. {
  41. }
  42.  
  43. virtual BarType getType(void)
  44. {
  45. return Hello;
  46. }
  47. };
  48.  
  49. int main(int argc, char* argv[])
  50. {
  51.  
  52. Bar f = Bar();
  53.  
  54. std::cout << f.getType() << std::endl;
  55.  
  56. return 0;
  57. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:43:18: error: conflicting return type specified for 'virtual BarType Bar::getType()'
prog.cpp:26:14: error:   overriding 'virtual int Foo::getType()'
stdout
Standard output is empty