C++ Format for cout << Automatically -


if had simple class 2 variables, x , y, , function tostring() returns formatted string data. when call

cout << simpleclass << "\n"; 

anyone know way have simpleclass.tostring automatically called return correctly formatted string? i'm guessing there's way operator functions, don't know how this.

if you're asking how define such operator,

template<class chart, class traitst> std::basic_ostream<chart, traitst>& operator <<(std::basic_ostream<chart, traitst>& os, simpleclass const& sc) {     return os << sc.tostring(); } 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -