C
Christopher
Currently, the code I am fixing seems to have several different global
functions for each type, is written c-style, to convert different
types into 3 different text representations.
ie.
typedef int Distance;
std::string FormatForLogA(Distnace distance);
std::string FormatForLogB(Distance distance);
std::string FormatForLogC(Distance distance);
I like to overload operator << for a type when I am going to be
converting it into a text representation.
Problem here is that there are 3 different text representations for
each type!
Suppose we are dealing with a distance type...
Log A might expect something like "204"
Log B might expect something like "2m"
Log C might expect something like "204 centimeters"
How would you go about diffientatiing which format you want and still
use the idea of overloading op << ?
Can we even do this for those types that are just a typedef of a
primitive without altering the way the primitive type looks in a
stream?
functions for each type, is written c-style, to convert different
types into 3 different text representations.
ie.
typedef int Distance;
std::string FormatForLogA(Distnace distance);
std::string FormatForLogB(Distance distance);
std::string FormatForLogC(Distance distance);
I like to overload operator << for a type when I am going to be
converting it into a text representation.
Problem here is that there are 3 different text representations for
each type!
Suppose we are dealing with a distance type...
Log A might expect something like "204"
Log B might expect something like "2m"
Log C might expect something like "204 centimeters"
How would you go about diffientatiing which format you want and still
use the idea of overloading op << ?
Can we even do this for those types that are just a typedef of a
primitive without altering the way the primitive type looks in a
stream?