할당 연산자를 재정의하고 자체 할당 테스트를 수행하려고하는데 VC++ Express 2010에서 코드에 다음 오류가 발생합니다. (예 :VC++ Express 2010에서 템플릿 클래스의 오버로드 된 할당 연산자의 자체 할당 테스트에서 오류가 발생합니다.
1> c : \ users \ fatak \ documents \ visual 스튜디오 2010 \ projects \ ray 추적기 \ ray 추적기 \ test.h : 오류 C2440 : '==': ' 시험 *의 CONST "
#ifndef __TEST_H__
#define __TEST_H__
template <class T = unsigned int> class Test
{
public:
Test() : dummy(0U) {};
template <class U> Test(U value) : dummy(T(value)) {};
~Test() {};
template <class U> Test<T> &operator=(const Test<U> &rhs);
T getValue(void) const {return dummy;};
template <class U> friend class Test;
private:
T dummy;
};
template <class T> template <class U> Test<T> &Test<T>::operator=(const Test<U> &rhs)
{
if(this == &rhs)
return *this;
dummy = T(rhs.dummy);
return *this;
}
#endif //__TEST_H__
'에서'CONST 시험 *도 I는 상기 템플릿 오버라이드 할당 연산자 피연산자를 변경할 때 :
template <class T> template <class U> Test<T> &Test<T>::operator=(Test<U> & const rhs)
나는 다음과 같은 오류가 발생합니다 :
1> C : \ 사용자 \ fatak 문서 비주얼 스튜디오 2010 \ 프로젝트 \ 광선 추적 \ 광선 추적 \의 test.h (22) \ \ : 오류 C2440를 : '= = ':'Test * '에서'Test * const '로 변환 할 수 없습니다.
이유가 무엇입니까? 또는 어떻게 성공적으로자가 할당 테스트를 수행 할 수 있습니까?
건배!