Object.hpp:
class Object
{
public:
virtual ~Object();
};
Object.cpp:
#include "Object.hpp"
Object::~Object()
{
}
让我们编译它:
>clang++ -v
clang version 3.9.0 (branches/release_39)
Target: x86_64-pc-windows-msvc
Thread model: posix
>clang++ -Weverything -c Object.cpp
In file included from Object.cpp:1:
./Object.hpp:1:7: warning: 'Object' has no out-of-line virtual method definitions;
its vtable will be emitted in every translation unit [-Wweak-vtables]
class Object
^
1 warning generated.
但是Object确实有一个外联的虚拟方法,为什么Clang会产生这个警告呢?