// ThEz.hpp using namespace std; class ThEz { private: map <string, void*> mx_; public: void add( string name, void * ag ); template <typename T> T get( string name ); }; // ThEz.cpp // set method looks alright template <typename T> T ThEz::get( string name ) { T * rv = (T*) mx_[name]; return *rv; } // main.cpp int x = 50; ThEz th1; th1.add( "hello", &x ); int y = th1.get<int>("hello"); //error here cout << y;
g++
5.2.1
th1.add
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)