链接文件c ++时出现怪异错误

时间:2014-04-17 20:36:42

标签: c++ class linker

帮助! 我有三节课; Point,Neuron和CumulativeNeuron。我有源文件neurones.cpp。 当我链接我的文件时,它说:

~/Desktop/assign-8$ g++ point.o neuron.o cumulativeNeuron.o neurones.o
cumulativeNeuron.o:(.rodata._ZTI16CumulativeNeuron[_ZTI16CumulativeNeuron]+0x10): undefined reference to `typeinfo for Neuron'
collect2: error: ld returned 1 exit status

我无法理解这个错误!请帮忙 感谢。

1 个答案:

答案 0 :(得分:1)

您忘记实现(或可能链接)virtual类中的第一个Neuron函数。几个编译器在实现第一个虚函数的位置为类生成RTTI类型信息。如果您忘记实现该功能,则不会生成类型信息,并且链接失败。

相关问题