Consider the following:
In X.h:
class X
{
X();
virtual ~X();
};
X.cpp:
#inclu
I have a suspicion on this one that this is implementation defined behavior. Here's why
$10.3/8- "A virtual function declared in a class shall be defined, or declared pure (10.4) in that class, or both; but no diagnostic is required (3.2)."
GCC gives error such as below, which again, is highly suggestive (to me at least) about a non-standard implementation detail of implementing virtual functions
/home/OyXDcE/ccS7g3Vl.o: In function
X::X()': prog.cpp:(.text+0x6): undefined reference to
vtable for X' /home/OyXDcE/ccS7g3Vl.o: In functionX::X()': prog.cpp:(.text+0x16): undefined reference to
vtable for X' collect2: ld returned 1 exit status
I am confused if a diagnostic is really required from a compiler for the OP code, so thought of posting this, even as I risk downvotes :). Of course, a good compiler should I guess.