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

c++ - Function signature as a function template parameter -

How to call a javascript function after the page loads with a chrome extension? -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -