C++ “virtual” keyword for functions in derived classes. Is it necessary?

后端 未结 9 1407
遇见更好的自我
遇见更好的自我 2020-11-22 15:17

With the struct definition given below...

struct A {
    virtual void hello() = 0;
};

Approach #1:

struct B : public A {
           


        
9条回答
  •  情歌与酒
    2020-11-22 15:28

    They are exactly the same. There is no difference between them other than that the first approach requires more typing and is potentially clearer.

提交回复
热议问题