I've been trying to solve this problem for hours, but I couldn't find the solution. Code example:
class IColor { // color interface public: virtual void print(); }; class Color : public IColor { // abstract color class }; class RGB : public Color { // color implementation public: void print() { std::cout << "hi"; } }; int main() { IColor* col = new RGB(); col->print(); return 0; } However, the result of compilation are linker errors:
/home/snndAJ/ccnvQHgL.o:(.rodata._ZTI5Color[_ZTI5Color]+0x8): undefined reference to `typeinfo for IColor' /home/snndAJ/ccnvQHgL.o:(.rodata._ZTV5Color[_ZTV5Color]+0x8): undefined reference to `IColor::print()' collect2: error: ld returned 1 exit status (Not)working online example: https://ideone.com/YikYwe