Help! I have three classes; Point, Neuron, and CumulativeNeuron. And I have source file neurones.cpp. when I link my files it says:

~/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

I can't understand this error! please help Thanks.

有帮助吗?

解决方案

You have forgotten to implement (or perhaps to link) the first virtual function in the Neuron class. Several compilers generate the RTTI type info for a class at the point where the first virtual function is implemented. If you forget to implement that function, no type info is generated and linking fails.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top