【发布时间】:2016-11-06 12:23:32
【问题描述】:
我有一种情况,不允许我修改我的班级的头文件。我只想添加一个辅助函数来与我的一个函数一起使用.. 但不能完全弄清楚实现它的正确方法。通常我会尝试谷歌,但在那里找不到任何帮助。
这是我当前的代码:
template<typename T>
void Set<T>::doubleRotateRight(Elem *& node) {
// you fill in here
rotateRight(node->left);
rotateLeft(node);
//call private helper not defined in header
privmed();
}
void privmed(){
//out << "who" << endl;
}
但是,当我运行它时,我得到了错误:
error: there are no arguments to ‘privmed’ that depend on a template parameter, so a declaration of ‘privmed’ must be available [-fpermissive]
privmed();
对此的任何帮助都将令人难以置信!
【问题讨论】:
-
在 C++ 中,所有东西都必须在使用前声明。您是否尝试过将
privmed函数实现移到doubleRotateRight函数之前? -
投票结束为不清楚。需要关于什么可以修改和什么不能修改的信息;需要有关
privmed的用途的信息;需要有关目标的信息。 -
cmon.... 非常感谢
-
“我不允许修改头文件”。您显示的代码在那个头文件中,不是吗?
-
@CaptainGiraffe 代码在 .cpp 文件中。我可能错了,但很确定那不是标题
标签: c++