#include <cstdlib> struct Shape {}; struct Rect : public Shape {}; struct Elipse : public Shape {}; Shape* randomShape() { return (std::rand() % 2) ? new Rect() : new Elipse(); }
Standard input is empty
prog.cpp: In function ‘Shape* randomShape()’: prog.cpp:7:75: error: conditional expression between distinct pointer types ‘Rect*’ and ‘Elipse*’ lacks a cast Shape* randomShape() { return (std::rand() % 2) ? new Rect() : new Elipse(); } ^ prog.cpp:7:78: warning: control reaches end of non-void function [-Wreturn-type] Shape* randomShape() { return (std::rand() % 2) ? new Rect() : new Elipse(); } ^
Standard output is empty