Today I did a simple test:
struct C{virtual void f()=0;};
void C::f(){printf("weird\n");}
The program is fine, but for me it is strange when we use it =0, it means that the body of the function must be defined in the inherited classes, but it looks like I can still give it an implementation function.
I tried both GCC and VC, both OK. Therefore, it seems to me that this should be part of the C ++ standard.
But why is this not a syntax error?
The reason I might think is similar to C # having both an “interface” and “abstract” keywords, an interface cannot have an implementation, while an abstract can have some implementations.
Is this the reason for my confusion that C ++ should support this kind of weird syntax?