fork download
  1. struct Drawable {};
  2. struct Shape : Drawable {};
  3. struct Polygon : Shape {};
  4. struct Rectangle : Shape {};
  5.  
  6. void func(Rectangle*, Drawable*, Drawable*) {}
  7. void func(Rectangle*, Rectangle*, Drawable*) {}
  8. void func(Polygon*, Rectangle*, Rectangle*) {}
  9.  
  10. Rectangle* create_rectangle()
  11. {
  12. return new Rectangle;
  13. }
  14.  
  15. int main()
  16. {
  17. Drawable* x = create_rectangle();
  18. Drawable* y = create_rectangle();
  19. Drawable* z = create_rectangle();
  20. func(x, y, z);
  21. }
  22.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:20:16: error: invalid conversion from ‘Drawable*’ to ‘Rectangle*’ [-fpermissive]
    func(x, y, z);
                ^
prog.cpp:6:6: note:   initializing argument 1 of ‘void func(Rectangle*, Drawable*, Drawable*)’
 void func(Rectangle*, Drawable*, Drawable*)  {}
      ^~~~
stdout
Standard output is empty