Hmm, is this really supposed to work?😄
class CBase { public: virtual void pureMethod() = 0; }; void CBase::pureMethod(void) { Alert(__FUNCTION__); } class CChild : public CBase { public: void pureMethod() override { CBase::pureMethod(); } }; void OnStart() { CChild child; child.pureMethod(); }
Vladislav Boyko:
This code compiles without any errors or warnings:
Is it normal for the compiler to ignore method definition? This is deliberately incorrect code that contradicts itself.
Although I probably want too much feedback from the compiler😄
Of course, why not ?
A pure virtual method means the class is abstract and can't be instantiated.
And that the subclass must implement this method (or it will be abstract too). It says nothing about a default implementation.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
This code compiles without any errors or warnings:
Is it normal for the compiler to ignore method definition? This is deliberately incorrect code that contradicts itself.
Although I probably want too much feedback from the compiler😄