dynamic_cast operator in C++# Programming - 葵花宝典
i*p
1 楼
How to understand this sentence.
The class of the object passed to the dynamic_cast operator must be part of
the hierarchy the object is being cast to.
To discuss it easily, I have following statements.
A *ap;
....
B *bp = dynamic_cast(ap);
1. Which class, A or B is "The class of the object passed to the dynamic_
cast operator"? I guess it is A.
2. Class B should be "the object is being cast to", right?
The class of the object passed to the dynamic_cast operator must be part of
the hierarchy the object is being cast to.
To discuss it easily, I have following statements.
A *ap;
....
B *bp = dynamic_cast(ap);
1. Which class, A or B is "The class of the object passed to the dynamic_
cast operator"? I guess it is A.
2. Class B should be "the object is being cast to", right?