#include <iostream>
#include <string>
#include <sstream>
using namespace std;
class MultiString {
std::string str;
public:
MultiString( std::string t ) : str(t) {}
template< class T >
T To() {
stringstream temp;
temp << str;
T output;
temp >> output;
return output;
}
};
int main() {
MultiString test("100.8");
cout << test.To<int>() << endl;
cout << test.To<double>() << endl;
cout << test.To<string>() << endl;
} |