템플릿 클래스에 operator=
을 오버로드하려고합니다.C++ 오류 C2801 : 'operator ='은 (는) 비 정적 멤버 여야합니다.
나는이 템플릿 클래스가 있습니다
template <class T>
class Matrice
{
T m,n;
public:
template <class V>
friend Matrice<V>& operator=(const Matrice<V> &);
};
template <class T>
Matrice<T>& Matrice<T>::operator=(const Matrice<T> &M)
{
/*...*/
return *this;
}
을 나는 또한 시도 :
template <class T>
class Matrice
{
T m,n;
public:
template <class V>
Matrice<V>& operator=(Matrice<V> &);
};
template <class T>
Matrice<T>& operator=(Matrice<T> &M)
{
/*...*/
return *this;
}
하지만, 난 여전히이 오류를 얻을 :
error C2801: 'operator =' must be a non-static member
두 번째 예는'friend' 문제를 해결할 수 있지만 해상도가 없습니다. – chris
오류 메시지를 읽었습니까? –
@Griwes 아무도 내 질문에 맞지 않을 때 개선 할 수 없습니다. –