c++ - ostream implementatuon using printf -
how implement ostream
-like class scratch using printf
only?
me looks problem in choosing format string ,which equal identifying input`s type , treating precision
i assume mean overloads operator<<
"an ostream
-like class". it's easy identify type of argument function having overloads. example, might have:
ostreamlike& ostreamlike::operator<<(int x) { printf("%d", x); return *this; } ostreamlike& ostreamlike::operator<<(float x) { printf("%f", x); return *this; }
the format of output determined whichever overload picked.
Comments
Post a Comment