什么是“虚拟公共”关键词? [英] What is "virtual public" keyword?

查看:82
本文介绍了什么是“虚拟公共”关键词?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在下面看到了一些奇怪的代码。

I've seen some strange code below.

class AA
{};
class BB: virtual public AA
{};



什么是虚拟公众是什么意思?在那里它可以改成虚拟私人和虚拟保护?



如果是这样,它们之间有什么区别?



有人注意到我。


What is the "virtual public" means? And there it can be changed into "virtual private" and "virtual protected"?

If so, what is the difference between them?

Anyone notice me.

推荐答案

virtual 的这种特定用途是相关的C ++的一个非常精细的特性,特别是C ++,称为虚拟基类。您可以从本手册的这一章了解它的工作原理:

http ://www.learncpp.com/cpp-tutorial/118-virtual-base-classes [ ^ ]。



这是与C ++ 倍数相关的某种复杂性继承的。如果在继承图上的多个继承路径中具有相同的继承成员,则它们的含义可能不明确。 C ++提供了两种从基类派生的方法,两种继承选项。



-SA
This specific use of virtual is related to quite a delicate feature of C++, specific to C++, called virtual base classes. You can understand how it works from this chapter of this manual:
http://www.learncpp.com/cpp-tutorial/118-virtual-base-classes[^].

This is some kind of complexity related to C++ multiple inheritance. When you have the same inherited members in more then one inheritance path on the inheritance graph, their meaning could be ambiguous. C++ offers two ways to derive from a base class, two options for inheritance.

—SA


这篇关于什么是“虚拟公共”关键词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆