// this tests if template method works. #ifdef DONTWORK struct A { template operator T*(); }; template A::operator T*(){ return 0; } template <> A::operator char*(){ return 0; } // specialization template A::operator void*(); // explicit instantiation template class string { public: template int compare(const T2&); template string(const string& s) { /* ... */ } // ... }; /* template template int string::compare(const T2& s) { // ... } */ #endif class MyClass { public: void * memory; template bool set(T value); // template T get(); bool set(int val); bool set(float val); // int get(); // float get(); MyClass() { memory = 0; }; }; template MyClass::set(T value) { if (memory != 0) delete memory; (T*)memory = new T; *(T*)memory = value; }; /* template T MyClass::get() { return *(T*)memory; } */ int main () { MyClass obj; int i = 10; float f = 2.3; obj.set(i); obj.set(f); return 0; }