的dynamic_cast<> perfomans [英] dynamic_cast<> perfomans

查看:79
本文介绍了的dynamic_cast<> perfomans的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好。


回到手工类型识别问题,告诉我,对于

普通继承是C ++保证


dynamic_cast<派生*>(基础*)


可以类似地实现


return(Base * - > type_fild> = Derived_typeid)?基数*:0;


-

Maksim A. Polyanin


"在这个仙女世界故事卷很喜欢olso"

/ Gnume /

解决方案

* Grizlyk:


你好。


回到手工类型识别的问题,告诉我,对于

普通继承是C ++保证


dynamic_cast<派生*>(基础*)



这是无效的C ++语法。参数必须是一个值,而不是一个类型。


可以类似地实现


return(基数* - > type_fild> = Derived_typeid)?基数*:0;



同上。


但如果我理解你正确的话,你想知道每个节点是否都是$ b可以为树中的$ b(对应于类的节点)分配一个数字,例如,NumberOf(A)> = NumberOf(B)表示A是B的父节点或

等于B.


答案是否定的,因为两个不相关的节点必须

具有相同的数字(不正确)暗示它们是相同的)或

不等数(错误地暗示一个是另一个的父节点)。


但是,亲子关系可以表示为矩阵。


这意味着如果用矩阵查找替换''> ='',你就可以做到。


-

答:因为它弄乱了人们通常阅读文字的顺序。

问:为什么这么糟糕?

A:热门发布。

问:使用过程中最烦人的事情是什么net和电子邮件?


" Grizlyk" < gr ****** @ yandex.ruwrote in news:eq ********** @ aioe.org:


你好。


回到手工类型识别问题,告诉我,对于

普通继承是C ++保证


dynamic_cast< Derived *>(基础*)


可以类似地实现


return(Base * - > type_fild> = Derived_typeid)?基础*:0;



请使用真实代码来表达您想要完成的任务。甚至

然后,你的伪代码仍然是错误的。你可以从dynamic_cast返回

的指针可以是除了pointerToBase和0之外的其他东西。

我想另一个问题,你为什么要这样做?什么是错的

dynamic_cast?




Alf P. Steinbach写道:
< blockquote class =post_quotes>
> * Grizlyk:


> Hello。

返回手册类的问题类型识别,告诉我,对于普通继承是C ++保证

dynamic_cast<派生*>(基础*)



这不是有效的C ++语法。参数必须是值,而不是类型。



它是仅包含要投射的类型的伪代码。


>


>可以类似地实现

return(Base * - > type_fild> = Derived_typeid)?基数*:0;



同上。



相同的加号成员" type_fild" &安培; " Derived_typeid"


但是如果我理解你正确的想知道是否每个节点都在一个

树中(与类对应的节点) )可以分配一个数字,使得

NumberOf(A)> = NumberOf(B)意味着A是B的父节点或等于B的父节点。 br />

答案是否定的,因为两个不相关的节点必须

具有相同的数字(错误地暗示它们是相同的)或

不等数(错误地暗示一个是另一个的父节点)。



问题是如果没有那么多?为了节省空间和高性能,必须如何实现(通过

C ++标准推荐)?这对我来说很重要 - 是

C ++保证dynamic_cast的时间<在普通继承的情况下

等于一二伪表达式if-else


return(Base * - > type_fild> = Derived * - > type_fild)?基地*:0;


或不是?


-

Maksim A. Polyanin


在这个童话故事世界中,人们喜欢olso"

/ Gnume /


Hello.

Returning to question of manual class type identification, tell me, for
ordinary inheritance is C++ garantee that

dynamic_cast<Derived*>(Base*)

can be implemented similarly to

return (Base*->type_fild >= Derived_typeid)? Base*: 0;

--
Maksim A. Polyanin

"In thi world of fairy tales rolls are liked olso"
/Gnume/

解决方案

* Grizlyk:

Hello.

Returning to question of manual class type identification, tell me, for
ordinary inheritance is C++ garantee that

dynamic_cast<Derived*>(Base*)

That''s not valid C++ syntax. The argument must be a value, not a type.

can be implemented similarly to

return (Base*->type_fild >= Derived_typeid)? Base*: 0;

Ditto.

But if I understand you correctly you''re wondering whether every node
in a tree (nodes corresponding to classes) can be assigned a number such
that NumberOf(A) >= NumberOf(B) implies that A is a parent node of B or
equal to B.

And the answer to that is no, because two unrelated nodes would have to
have either equal numbers (incorrectly implying they''re the same) or
unequal numbers (incorrectly implying one is a parent node of the other).

However, the parent-child relationships can be represented as a matrix.

Which means that if you replace ''>='' with a matrix lookup you can do it.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


"Grizlyk" <gr******@yandex.ruwrote in news:eq**********@aioe.org:

Hello.

Returning to question of manual class type identification, tell me, for
ordinary inheritance is C++ garantee that

dynamic_cast<Derived*>(Base*)

can be implemented similarly to

return (Base*->type_fild >= Derived_typeid)? Base*: 0;

Please use real code to express what you''re trying to accomplish. And even
then, your pseudo code is still wrong. The pointer that you can get back
from dynamic_cast can be something other than pointerToBase and 0.
I guess the other question, is why would you want to? What''s wrong with
dynamic_cast ?



Alf P. Steinbach wrote:

>* Grizlyk:

>Hello.

Returning to question of manual class type identification, tell me, for
ordinary inheritance is C++ garantee that

dynamic_cast<Derived*>(Base*)


That''s not valid C++ syntax. The argument must be a value, not a type.

it is pseudo code containing only types to cast.

>

>can be implemented similarly to

return (Base*->type_fild >= Derived_typeid)? Base*: 0;


Ditto.

The same plus members "type_fild" & "Derived_typeid"

But if I understand you correctly you''re wondering whether every node in a
tree (nodes corresponding to classes) can be assigned a number such that
NumberOf(A) >= NumberOf(B) implies that A is a parent node of B or equal
to B.

And the answer to that is no, because two unrelated nodes would have to
have either equal numbers (incorrectly implying they''re the same) or
unequal numbers (incorrectly implying one is a parent node of the other).

The question is "if no that how"? How it must be implemented (recomended by
C++ standard) to save space and high perfomance? It is importan to me - is
C++ garantee the time of dynamic_cast<in the case of ordinary inheritance
is equal to one-two pseudo expression "if-else"

return (Base*->type_fild >= Derived*->type_fild)? Base*: 0;

or not?

--
Maksim A. Polyanin

"In thi world of fairy tales rolls are liked olso"
/Gnume/


这篇关于的dynamic_cast&LT;&GT; perfomans的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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