template_constructor_function
#include <iostream> using namespace std; template <class T> class MyClass{ public: template<class U> MyClass(const MyClass<U>& x) { cout<<"MyClass(const MyClass<U>& x)"<<endl; } MyClass(const MyClass<T>& x) { cout<<"MyClass(const MyClass<T>& x)"<<endl; } MyClass() { cout<<"MyClass()"<<endl; } }; void main() { MyClass<double> xd; cout<<"========================"<<endl; MyClass<int> xi(xd); cout<<"========================"<<endl; MyClass<int> yi(xi); /* MyClass() ======================== MyClass(const MyClass<U>& x) ======================== MyClass(const MyClass<T>& x) Press any key to continue */ }