What's the difference between virtual function instantiations in C++?

后端 未结 8 1892
栀梦
栀梦 2021-01-25 07:30

What\'s the difference between the following two declarations?

virtual void calculateBase() = 0;  
virtual void calculateBase();

I read the fir

8条回答
  •  北恋
    北恋 (楼主)
    2021-01-25 07:56

    The second function must have an implementation in the class that declare it (lack of '= 0'), and can be overriden by subClasses.

    The first function may or not have an implementation in the class that declare it, and has to be implemented by subClasses

提交回复
热议问题