当我尝试在我的 mingw32 编译器上编译此代码时,我没有收到匹配的成员函数错误
#include <iostream>
using std::cout;
template <class T>
class Pattern
{
public:
Pattern(): element(){
cout<< "default c-tor";
}
Pattern(Pattern ©): element(copy.element){
cout<< "copy c-tor";
}
Pattern& operator=(Pattern &assgn)
{
cout<<" assignment operator";
element = assgn.element;
return *this;
}
~Pattern(){
cout<<"destructor";
}
private:
T element;
};
template <class T>
Pattern<T> creator()
{
cout<< "Testing creator";
Pattern<T> pat;
return pat;
}
int main()
{
Pattern<double> pt1(creator<double>());
Pattern<double> pt2 = creator<double>();
}
有人请告诉我如何解决这个问题。