加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 虚函数的显式覆盖

发布时间:2020-12-16 07:50:46 所属栏目:百科 来源:网络整理
导读:我刚刚发现C/C++LI在标准C:override上有一个不存在的关键字(AFAIK). 我对C/C++LI了解不多,所以,有人可以解释它包含在哪个目的,以及它是否是添加到C的理想功能? 解决方法 override 是Microsoft的特殊关键字扩展,可用于C/C++LI和Visual C实现.它类似于Java中
我刚刚发现C/C++LI在标准C:override上有一个不存在的关键字(AFAIK).

我对C/C++LI了解不多,所以,有人可以解释它包含在哪个目的,以及它是否是添加到C的理想功能?

解决方法

override是Microsoft的特殊关键字扩展,可用于C/C++LI和Visual C实现.它类似于Java中的 @Override注释或C#中的 override,并提供更好的编译时间检查,以防您没有覆盖您想要的内容.

从第一个链接:

override indicates that a member of a managed type must override a base class or a base interface member. If there is no member to override,the compiler will generate an error.

override is also valid when compiling for native targets (without /clr). See Override Specifiers and Native Compilations for more information.

override is a context-sensitive keyword. See Context-Sensitive Keywords for more information.

从C 11标准开始,覆盖说明符现在是标准化关键字.支持仍然有限,根据此page from Apache StdCxx,GCC 4.7,Intel C 12.0和Visual C 2012支持覆盖(在Visual C 2005中具有预标准化支持).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读