C++ 错误:函数未在此范围内声明。帮助

C++ 错误:函数未在此范围内声明。帮助,c++,C++,以下是我的代码(部分): 。。。 节点*节点[count2]//指向最后一级的指针数组 节点[0]=f1.rootPtr; processInput(输入,f1.rootPtr,节点,0,count2); //我得到一个错误,说这个函数没有在这个范围内声明。 返回输入; } void processInput(istream&input、节点*节点、节点**节点阵列、, 整数级别、整数和计数) { //变数 节点*阳极=新节点(); charchararray[150]; ... 当我运行程序

以下是我的代码(部分):

。。。
节点*节点[count2]//指向最后一级的指针数组
节点[0]=f1.rootPtr;
processInput(输入,f1.rootPtr,节点,0,count2);
//我得到一个错误,说这个函数没有在这个范围内声明。
返回输入;
}
void processInput(istream&input、节点*节点、节点**节点阵列、,
整数级别、整数和计数)
{
//变数
节点*阳极=新节点();
charchararray[150];
...
当我运行程序时,我得到以下信息:

Forest.cpp: In function 'std::istream& operator>>(std::istream&, Forest<char*>&)':
Forest.cpp:93:53: error: 'processInput' was not declared in this scope
make[2]: *** [build/Debug/MinGW-Windows/Forest.o] Error 1
make[1]: *** [.build-conf] Error 2
Forest.cpp:在函数“std::istream&operator>>(std::istream&,Forest&)”中:
Forest.cpp:93:53:错误:“processInput”未在此作用域中声明
生成[2]:***[build/Debug/MinGW Windows/Forest.o]错误1
生成[1]:***[.build conf]错误2
以下是头文件的一部分:

template<typename NODETYPE> class Forest{

    /*
     * builds a forests consisting of the first and second forest reference
     */
    template<NODETYPE>
    friend Forest& operator+(Forest<NODETYPE>& f1, Forest<NODETYPE>& f2);

    /*
     * insert into the output stream a preorder traversal of the input forest
     */
    template<NODETYPE>
    friend ostream& operator<<(ostream& ostr, const Forest<NODETYPE>& f1);

    /*
    * extracts a forest from the input stream and builds it for the forest argument variable name
    */
    //template<NODETYPE>
    friend istream& operator>>(istream& file, Forest<char*>& f1);

    /*
     *Used with istream to go through input
     */
    //template<NODETYPE>
    void processInput(istream& input, Node<char*>* nodeBefore, Node<char*> ** nodeArray,
        int levelBefore, int& count);

public:
    Forest(){

..
模板类林{
/*
*构建由第一个林引用和第二个林引用组成的林
*/
样板
朋友林和操作符+(林和f1,林和f2);
/*
*在输出流中插入输入林的前序遍历
*/
样板
friend ostream&operator(istream&file,Forest&f1);
/*
*与istream一起使用以通过输入
*/
//模板
void processInput(istream&input、节点*节点前端、节点**节点阵列、,
int levelBefore、int和count);
公众:
森林(){
..
我做错了什么?为什么我会犯这样的错误。有什么建议吗

谢谢

编辑:

我试过你说的,但仍然不起作用。虽然我在使用模板,所以也许这就是我的问题所在

标题:

模板//我应该保留这个吗?当我把它拿出来时,它也不起作用 friend istream和operator>>(istream和文件、林和f1)

私人:
void processInput(istream&input、节点*节点、节点**节点阵列、, 整数级、整数和计数)

.cpp文件:

模板 istream和运算符>>(istream和输入、林和f1){ //代码 ... processInput(输入,f1.rootPtr,节点,0,count2); //错误:无法解析标识符processInput }

/** *处理输入 / void-Forest::processInput(istream&input、节点节点、节点**nodeArray、int-level、int&count){ //代码


再次感谢。

您需要在类函数前面加上它们的类名,您当前是否这样做?如果不这样做,编译器会认为它们是自由函数

比如说,

void processInput(istream& input, Node<char*>* node, Node<char*>** nodeArray,
    int level, int& count) {
    // ...code...
}
void processInput(istream&input、节点*节点、节点**节点阵列、,
整数级别、整数和计数){
//…代码。。。
}
应该是

void Forest::processInput(istream& input, Node<char*>* node, Node<char*>** nodeArray,
    int level, int& count) {
    // ...code...
}
void林::processInput(istream&input,节点*节点,节点**节点阵列,
整数级别、整数和计数){
//…代码。。。
}

当然,只有定义,而不是类本身内部的声明。
void Forest::processInput(istream& input, Node<char*>* node, Node<char*>** nodeArray,
    int level, int& count) {
    // ...code...
}