【发布时间】:2012-05-03 06:04:53
【问题描述】:
unsigned char *check = NULL;
check = (dynamic_cast<unsigned char *>( ns3::NetDevice::GetChannel() ));
这就是我正在尝试的。但错误是:
error: cannot dynamic_cast ‘ns3::NetDevice::GetChannel() const()’ (of type ‘class ns3::Ptr<ns3::Channel>’) to type ‘unsigned char*’ (target is not pointer or reference to class)
我也试过了:
reinterpret_cast
但它根本不起作用。
【问题讨论】:
-
reinterpret_cast应该可以工作。 -
重新解释演员表应用非常危险。但我已经这样做了。无法解决问题。完全没有。
-
ns3::NetDevice::GetChannel()的返回类型是什么?
-
codevirtual Ptr GetChannel (void) const =0 -
@alee-sindhu:那么
Ptr是什么?如果没有它的定义,我们只能猜测如何将其转换为原始指针。
标签: c++ inheritance casting polymorphism ns-3