Requiring virtual function overrides to use override keyword

后端 未结 4 1922
孤独总比滥情好
孤独总比滥情好 2020-12-29 01:47

C++11 added override to ensure that member functions you write that you intend to override base-class virtual functions actually do (or won\'t compile).

4条回答
  •  甜味超标
    2020-12-29 01:54

    Looks like the GCC 5.1 release added exactly the warning I was looking for:

    -Wsuggest-override
           Warn about overriding virtual functions that are not marked with the override keyword.

    Compiling with -Wsuggest-override -Werror=suggest-override would then enforce that all overrides use override.

提交回复
热议问题