I get a linker error in my code. I accurately defined it lower than lower.
This code gives the linker error "vtable for Foo" referenced: Foo :: Foo ()
class Foo { public: Foo(); virtual ~Foo() = default; }; Foo::Foo() { }
But this code does not give any errors:
class Foo { public: Foo(); virtual ~Foo() { } }; Foo::Foo() { }
Why? I thought that = default was supposed to basically do the same thing as empty square brackets.
Update: I am using the "Apple LLVM compiler 4.1", part of Xcode 4.5.2. Maybe this is a bug in this compiler? Perhaps it works with the latest GCC (which Apple no longer sells). See the comments below for a discussion of compilers.
Update 2: As discussed below, changing this line to virtual inline ~Foo() = default; fixes this error. Isn't it just a mistake? It seems that the compiler does not recognize the built-in function in this case, without explicitly writing inline .
source share