我不清楚什么时候需要在const中使用dynamic_pointer_cast或dynamic_cast。请给我解释一下。我创建了一个类型为A的const对象,但据我所知,在downcast中没有必要将dynamic_pointer_cast与const一起使用,那么什么时候需要const downcast?y = 11;
{ auto b = st
需要哪个非虚拟子类由运行时的GUI选择决定。 basePtr->methodUniqueToA(); // COMPILE ERROR // I could check the type using dynamic_pointer_castif(dynamic_pointer_cast<A>(basePtr))
我有以下代码,两个对象指针--一个Base和一个Derived (从基本对象派生)--允许存储在基对象指针向量中,当读取向量时,我需要检查是否需要dynamic_pointer_cast指针,这样数据就不会被切分temporary location and move it back when done
if (std::shared_ptr<Derived> tmp_ptr = std::move(std::dynamic_pointer_cast// #2