私のヘッダーファイルには
template <typename T>
class Vector {
public:
// constructor and other things
const Vector& operator=(const Vector &rhs);
};
ここに私がこれまでに試した1つの宣言があります
template <typename T> Vector& Vector< T >::operator=( const Vector &rhs )
{
if( this != &rhs )
{
delete [ ] array;
theSize = rhs.size();
theCapacity = rhs.capacity();
array = new T[ capacity() ];
for( int i = 0; i < size(); i++ ){
array[ i ] = rhs.array[ i ];
}
}
return *this;
}
これはコンパイラが私に言っていることです
In file included from Vector.h:96,
from main.cpp:2:
Vector.cpp:18: error: expected constructor, destructor, or type conversion before ‘&’ token
make: *** [project1] Error 1
コピーコンストラクターを正しく宣言するにはどうすればよいですか?
注: これはプロジェクト用であり、ヘッダー宣言を変更できないため、このような提案は便利ですが、この特定のインスタンスでは役に立ちません。
助けてくれてありがとう!