Wednesday, December 07, 2005

c++ Type Conversions Rehash

Another popular way to write this function is by using templates.
template <typename T>
string toString(T& i) {
ostringstream oss;
oss << fixed << i;
return oss.str();
}
This should be put in a header file and needs the following:
sstream
iomanip
string

0 Comments:

Post a Comment

<< Home