The problem with overloaded operators is that they are not virtual. So to solve that, I'd suggestion you do something like this:
Code:class Shape { ... public: ... virtual void Draw(ostream& os) = 0; }; class Line : public Shape { ... public: ... virtual void Draw(ostream& os); }; void Line::Draw(ostream &os) { ... do your ACTUAL drawing for line, using basic << operator. } ostream& operator << (ostream& os, const Shape& sh) { sh.Draw(os); return os; }
That way, each drawing can do it's own thing, but you can still use a generic form with << .
--
Mats