+ 1
virtual functions codebit
https://www.sololearn.com/compiler-playground/c9069SBHc1dk in line 9 : virtual void speak() = 0; cant we declare this func as just void (without virtual) and why did we put = 0
1 ответ
+ 2
Yes. You can but no longer virtual function. It Becomes a normal function.
virtual void speak() = 0; is making it pure virtual function, telling the compiler that is has no implementation. Derived class provides it's implementation.
Making it virtual, provides Polimorphic feature that it invoke methods depends on the initialization.