Re: dynamic_cast<> perfomans
* 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?