operator = をオーバーロードしようとすると、エラーが発生しました。
コードの何が問題なのかわかりません。手伝ってくれてありがとう!
これが私のコードです:
マトリックス.h
namespace MATRIX{
class Matrix{
// other private methods
public:
// other public methods
template < typename T >
Matrix& operator=(std::list<T> & data) ;
}
};
マトリックス.cu
namespace MATRIX{
// other definitions
template < typename T >
Matrix& Matrix::operator=(list<T> & data) {
// method definition
}
}
test.cu
#include <list>
#include "matrix.h"
// other includes
int main(void){
using namespace std;
using MATRIX::Matrix;
Matrix k_matrix;
list<double> k_list(100);
// initialize k_list
k_matrix = k_list;
}
建てる
nvcc -c matrix.cu
nvcc -o test test.cu matrix.o
2 番目のコマンドのエラー
tmpxft_00001f0f_00000000-3_test.cudafe1.cpp:(.text+0x202):
undefined reference to`MATRIX::Matrix& MATRIX::Matrix::operator=<double>
(std::list<double, std::allocator<double> >&)'