class MyClass {
public:
register_callback(int, void*);
}
typedef boost::shared_ptr<MyClass> myClass_p;
class MyOtherClass {
public:
registerItem(std::pair<std::string, myClass_p>insertItem) {
auto foo = insertItem.second;
void *bar = static_cast<void*>(foo);
}
鉴于上面的代码,为什么会收到“的static_cast:。不能从myClass_p转换为void *我想你可以施放任何指针为void *不能转换为void *
'foo'不是指针;它是一个'boost :: shared_ptr'。 –
Justin
@CaptainObvlious我不认为隐式转换为void *'在C++中 – NathanOliver
@NathanOliver这并不完全清楚。我指的是不是'boost :: shared_ptr'的指针。 –