GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: Add Line Numbers


A Paste by Anonymous
#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;
}