如果我聲明:C++模板和繼承與方法指針
class Avoidance : public Schema<std_msgs::String,prog1::Command>{
我嘗試
void*(Schema<std_msgs::String,prog1::Command>::*pt)();
pt=&Avoidance::frontBusy;
編譯舉報我
error: cannot convert ‘void* (Avoidance::*)()’
to
‘void* (Schema<std_msgs::String_<std::allocator<void> >, prog1::Command_<std::allocator<void> > >::*)()’ in assignment
爲什麼呢?避免繼承
Schema<std_msgs::String,prog1::Command>
然後避免是架構< .....>
你的答案是這裏給出:爲什麼我不能投一個指向派生類的成員函數相同,但Base類](http://stackoverflow.com/questions/10162823/why-cant -i-cast-a-pointer-derived-class-member-function-to-the-same-but-of-c) –