我有我的基类,如下所示:C++继承向下转换
class point //concrete class
{
... //implementation
}
class subpoint : public point //concrete class
{
... //implementation
}
如何从一个点对象转换为下点对象?我已尝试以下所有三种方法:
point a;
subpoint* b = dynamic_cast<subpoint*>(&a);
subpoint* b = (subpoint*)a;
subpoint b = (subpoint)a;
这些演员出了什么问题?
将被铸造的对象实际上是类型的子点,它只是在一个点数组中。 – CodeKingPlusPlus 2012-08-08 13:00:52