c++ - operator<< doesn't find match -


    class shape     {         virtual void out() = 0;     };      std::ostream& operator<<(std::ostream& os, shape& a)     {         return os << a.out();     } 

i want create abstract base class , able use cout << triangle/square etc. later on, triangle, square being derived classes shape.

it works fine if return os << "test"; i'm guessing it's a.out() not getting called properly, can't seem pinpoint problem.

the out member function returns void, doesn't return object pass std::ostream::operator<<. perhaps want return std::string?


Comments

Popular posts from this blog

Winapi c++: DialogBox hangs when breaking a loop -

vb.net - Font adding using PDFsharp -

javascript - jQuery iScroll clickable list elements while retaining scroll? -