Full Source code: https://github.com/amreo/gridb/tree/devel
I'm in trouble with my opensource library I've two class AbstractMapTile in src/abstractmaptile.h and MapTile in src/maptile.h
class AbstractMapTile : public virtual AbstractLocated, public QObject
and
class MapTile : public AbstractMapTile, public Located
I'm in trouble how to implement the destructor in MapTile and how to manage inheriting of MapTile and AbstractMapTile.
I've tried to put
virtual ~AbstractMapTile() = 0;
in AbstractMapTile and
~MapTile() {}
in MapTile but I get these errors from linker:
g++ -m64 -Wl,-O1 -o test main.o moc_tests.o -L/home/amreo/src/repo/gridb/gridb/test/../bin/ -lgridb -lQt5Test -lQt5Core -lpthread
moc_tests.o: In function `MapTile::~MapTile()':
moc_tests.cpp:(.text._ZN7MapTileD1Ev[_ZN7MapTileD1Ev]+0x1a): undefined reference to `AbstractMapTile::~AbstractMapTile()'
moc_tests.o: In function `MapTile::~MapTile()':
moc_tests.cpp:(.text._ZN7MapTileD0Ev[_ZN7MapTileD0Ev]+0x1e): undefined reference to `AbstractMapTile::~AbstractMapTile()'
moc_tests.o: In function `Test::testMapTileCostructor1()':
moc_tests.cpp:(.text._ZN4Test22testMapTileCostructor1Ev[_ZN4Test22testMapTileCostructor1Ev]+0x1ee): undefined reference to `AbstractMapTile::~AbstractMapTile()'
moc_tests.o: In function `Test::testMapTileCostructor2()':
moc_tests.cpp:(.text._ZN4Test22testMapTileCostructor2Ev[_ZN4Test22testMapTileCostructor2Ev]+0x2e4): undefined reference to `AbstractMapTile::~AbstractMapTile()'
moc_tests.o: In function `Test::testMapTileCostructor3()':
moc_tests.cpp:(.text._ZN4Test22testMapTileCostructor3Ev[_ZN4Test22testMapTileCostructor3Ev]+0x2e8): undefined reference to `AbstractMapTile::~AbstractMapTile()'
moc_tests.o:moc_tests.cpp:(.text._ZN4Test22testMapTileCostructor3Ev[_ZN4Test22testMapTileCostructor3Ev]+0x37d): more undefined references to `AbstractMapTile::~AbstractMapTile()' follow
This is test code:
AbstractMapTile* mapTile = new MapTile(10,20,nullptr);
QCOMPARE(mapTile->x(), 10);
QCOMPARE(mapTile->y(), 20);
QVERIFY(mapTile->map() == nullptr);
delete mapTile;