The error message seems to be little mis-leading with the scenario, when we try to delete
a virtual
method.
prog.cpp:4:16: error: deleted function 'virtual void Test::foo()'
prog.cpp:8:2: error: used here
Code
struct Test : public Base
{
Test() {}
virtual void foo () = delete; // error
};
Are virtual
method not delete
able for the same reason, why they cannot remain unimplemented in C++03 ? Is there any way to mention that Test
purposely not implementing virtual foo()
?
The term use has a concrete definition in the standard, and in particular for virtual functions the definition of odr-used is:
§3.2/2 (C++0x FDIS) [...]A virtual member function is odr-used if it is not pure.[...]
Where odr-used is a new term in the upcoming standard that refers to what the previous standard called plainly used:
§3.2/2 (current standard) [...]A virtual member function is used if it is not pure.[...]
My take is that the error message employs the term used to refer to odr-used in this particular case, and yes, the reason why this is a violation is exactly the same reason by which you cannot leave a non-pure virtual member function unimplemented.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With