Hi,
I have a class qgl in namespace mtl.
If I define the ctor/dtor in the header it compiles ok, if in the .cpp file it says while linking:
Code:
undefined reference to `vtable for mtl::qgl'
collect2: error: ld returned 1 exit status
if I define the ctor/dtor in both .h and .cpp files (that is twice to see what happens), it says "error: redefinition"
Code:
/media/docs/dev/Learn/mtl/qgl.cpp:13:1: error: redefinition of ‘mtl::qgl::qgl()’
In file included from /media/docs/dev/Learn/mtl/qgl.cpp:1:0:
/media/docs/dev/Learn/mtl/qgl.hpp:16:2: error: ‘mtl::qgl::qgl()’ previously defined here
/media/docs/dev/Learn/mtl/qgl.cpp:17:1: error: redefinition of ‘mtl::qgl::~qgl()’
In file included from /media/docs/dev/Learn/mtl/qgl.cpp:1:0:
/media/docs/dev/Learn/mtl/qgl.hpp:18:10: error: ‘virtual mtl::qgl::~qgl()’ previously defined here
Any ideas why it's so weird? That is, it find the ctor/dtor in the header file but in the .cpp file only in some cases.
Bookmarks