【发布时间】:2017-04-22 06:41:14
【问题描述】:
class Btree{
friend void visitNode_(BtreeNode<T>* node);
void DFSshow();
void showNode_(BtreeNode<T>* node,int step,void (*func)(BtreeNode<T>*));
}
template <class T>
void Btree<T>::DFSshow() {
void (*ptr)(BtreeNode<T>*);
ptr = &visitNode_;
this->showNode_(root,0,ptr);
}
template<class T>
void visitNode_(BtreeNode<T> *node) {
node->showNode();
}
我想将友元函数指针传递给成员函数。
errors:In file included from /Users/wangruoxuan/ClionProjects/btree/main.cpp:2:
/Users/wangruoxuan/ClionProjects/btree/Btree.hpp:157:12: error: use of undeclared identifier 'visitNode_'
ptr = &visitNode_;
^
1 error generated.
【问题讨论】:
标签: c++ templates friend-function