This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

interface-> undefined symbol typeinfo

Hello together,

i´m trying for the first time to use an interface. To do this i´m doing a very simple interface wich has only one "doIt()" Method. I made two Classes wich inherit in the header from this Interface and implement the "doIt()" Method. One object simply adds "3" to a given argument and the other just substracts "2" from the argument. These two classes are instantiatet in an object and adresses are stored in an array of the type from the interface. If i just compile "the active
file" while everything is ok even if i go up until the main file. But when i accually build the project i get the
massage "undefined symbol type info for Interface_X". The odd thing is, i just get it for one of the classes
which inherit the interface and it´s allways the same class no matter in which order i instantiate them.
But they are both exacly the same execept for the +3 and -2 thing and the class names.
Is there an typical mistake i could have done?

Jasson

  • One way that undefined typeinfo can happen when there are virtual functions that are declared but not defined (or they are defined but not linked).

    The forum might be able to help more if you can show us the code, command lines and and the error messages for a small case.

  • ...i found the problem.
    It was the "=0" Statement in the Interface´s header file behind the virtual function.
    Stupid thing is, i know i read about that yesterday evening, but probably dis something wrong with my outpowered brain...
    Today i simply tryed randomly what came to my mind.

  • =0 means that you have shown what the method prototype should look like. But demand that other classes inheriting from this base class must contain an actual implementation for you to be allowed to instantiate an object.

    The base class, being pure virtual, just shows the pattern how the class hierarchy is intended to be used while leaving it to someone else to actually write the code.