template extending
template <typename T> class SimpleTemplate { public: SimpleTemplate(T &inObject); const T& get(); void set(T& inObject); protected: T& mObject; }; template <typename T> SimpleTemplate<T>::SimpleTemplate(T &inObject) : mObject(inObject) { } template <typename T> const T& SimpleTemplate<T>::get() { return mObject; } template <typename T> void SimpleTemplate<T>::set(T& inObject) { mObject = inObject; } #include <iostream> #include <string> using namespace std; int main(int argc, char** argv) { int i = 7; SimpleTemplate<int> intWrapper(i); i = 2; cout << "wrapper value is " << intWrapper.get() << endl; string str = "test"; SimpleTemplate<string> stringWrapper(str); str += "!"; cout << "wrapper value is " << stringWrapper.get() << endl; }