首次引用的未定义符号

Undefined symbol first referenced

本文关键字:未定义 符号 引用      更新时间:2023-10-16

我是c++的新手,我正在学习模板类和动态内存分配,所以如果这里有愚蠢的错误,我道歉。我不能确切地告诉什么问题是在这段代码,但我似乎不能让编译器给我任何其他的…

Undefined                       first referenced
 symbol                             in file
indexList<timecard>::operator=(indexList<timecard> const&)/var/tmp//ccgqjCOv.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
template <class T>
indexList<T>& indexList<T>::operator=(const indexList<T> &other) const{
  if(this != &other){
    name = other.name;
    ssn = other.ssn;
    hours = other.hours;
    payRate = other.payRate;
    numOfDependents = other.numOfDependents;
    unionMem = other.unionMem;
    delete list;
    list = new T[maxSize];
    *list = *(other.list);
  }//end if
  return *this;
}

{之前的最后一个const限定符不属于那里。

我不知道为什么你得到这个特定的错误,因为函数实际上是定义的,但是所有的赋值name =等都是非法的,因为thisconst。但是,复制赋值操作符是一个特殊的函数,编译器确实不希望看到这个签名。