struct Drawable {};
struct Shape : Drawable {};
struct Polygon : Shape {};
struct Rectangle : Shape {};
void func(Rectangle*, Drawable*, Drawable*) {}
void func(Rectangle*, Rectangle*, Drawable*) {}
void func(Polygon*, Rectangle*, Rectangle*) {}
Rectangle* create_rectangle()
{
return new Rectangle;
}
int main()
{
Drawable* x = create_rectangle();
Drawable* y = create_rectangle();
Drawable* z = create_rectangle();
func(x, y, z);
}
c3RydWN0IERyYXdhYmxlIHt9OwpzdHJ1Y3QgU2hhcGUgOiBEcmF3YWJsZSB7fTsKc3RydWN0IFBvbHlnb24gOiBTaGFwZSB7fTsKc3RydWN0IFJlY3RhbmdsZSA6IFNoYXBlIHt9OwoKdm9pZCBmdW5jKFJlY3RhbmdsZSosIERyYXdhYmxlKiwgRHJhd2FibGUqKSAge30Kdm9pZCBmdW5jKFJlY3RhbmdsZSosIFJlY3RhbmdsZSosIERyYXdhYmxlKikgIHt9CnZvaWQgZnVuYyhQb2x5Z29uKiwgUmVjdGFuZ2xlKiwgUmVjdGFuZ2xlKikgIHt9CgpSZWN0YW5nbGUqIGNyZWF0ZV9yZWN0YW5nbGUoKQp7CiAgIHJldHVybiBuZXcgUmVjdGFuZ2xlOwp9CgppbnQgbWFpbigpCnsKICAgRHJhd2FibGUqIHggPSBjcmVhdGVfcmVjdGFuZ2xlKCk7CiAgIERyYXdhYmxlKiB5ID0gY3JlYXRlX3JlY3RhbmdsZSgpOwogICBEcmF3YWJsZSogeiA9IGNyZWF0ZV9yZWN0YW5nbGUoKTsKICAgZnVuYyh4LCB5LCB6KTsKfQo=
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*) {}
^~~~