>抽象基类Abstract1和Abstract2.他们是无关的.
>一个派生自Abstract1和Abstract2的Foo类
我在一个编译单位,我没有关于Foo类的信息(没有声明,没有定义).只有Abstract1和Abstract2是已知的.
(实际上,Foo甚至在DLL中定义)
将dynamic_cast允许从Abstract1 *转换为Abstract2 *?这是标准吗?
解决方法
If
C
is the class type to whichT
points or refers,the run-time
check logically executes as follows:
If,in the most derived object pointed (referred) to by
v
,v
points (refers) to a public base class subobject of aC
object [..]Otherwise,if
v
points (refers) to apublic
base class subobject of the most derived object,and the type of the most derived object
has a base class,of typeC
,that is unambiguous andpublic
,the
result points (refers) to theC
subobject of the most derived
object.
即使没有关于Foo在包含演员的翻译单元中的存在的信息,这将会工作.
你也应该看看this question.
原文地址:https://www.jb51.cc/c/110250.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。