flownt got it right, but I want to point out that in the final C++11 draft (N3337), the corresponding language has moved to section 10.3#16:
A function with a deleted definition shall not override a function
that does not have a deleted definition. Likewise, a function that
does not have a deleted definition shall not override a function with
a deleted definition.2
It seems fairly clear to me (section 8.4.3#1) that a deleted definition does in fact count as a definition, and in fact an inline definition, which means a deleted definition satisfies 10.3#11:
A virtual function declared in a class shall be defined, or declared
pure in that class, or both; but no diagnostic is required.2
However, it seems that current implementations disagree. Here's my test case:
struct Base {
virtual void bar();
virtual void foo() = delete;
};
void Base::bar() { } // a definition of the first non-inline virtual function
int main() { Base b; }
Clang produces an unlinkable program: Base::foo
is mentioned in the vtable for Base
. And if you swap the order of foo
and bar
, the linker complains that the entire vtable is missing (because Clang thinks foo
is a non-inline function with no definition). I filed this as a bug; we'll see what the developers think.
GCC complains about a "use" of foo
at the end of the translation unit, when it creates the vtable; but it does correctly identify bar
as the first non-inline virtual member function, no matter the order of foo
and bar
.