简体   繁体   English

函数无法识别我在 C++ 中传递节点指针向量?

[英]Function is not recognizing me passing a vector of node pointers, in C++?

I'm pretty new to C++, for a binary tree project, I am trying to pass a vector of node pointers into a function that will add/manipulate the tree.我对 C++ 很陌生,对于二叉树项目,我试图将节点指针向量传递给将添加/操作树的函数。 The errors are commented below.下面对错误进行了注释。

Example of one of the function's signatures:函数签名之一的示例:

void add(vector <Node*> &nodes, int &Aindex, vector <int> A, int value, vector <int> E, int Eindex);

Main code:主要代码:

vector <Node*> makeTree(vector <int> A, vector <int> E) {
    vector <Node*> nodes = {};
    int Aindex = 0;
    for (int i = 0; i < E.size(); i++) {
        if (i == 0 || i % 2 != 0) {
            if (i == 0) {
                create(nodes, Aindex, A, E[i]); // no matching function to call to ERROR.
            } else {
                add(nodes, Aindex, A, E[i], E, i); // no matching function to call to ERROR.
            }
            Aindex++;
        } else {
            if (find(nodes, Aindex, A, E[i]) == false) { // no matching function to call to ERROR.
                create(nodes, Aindex, A, E[i]); // no matching function to call to ERROR.
                Aindex++;
            } else {

            }
        }
    }
    return nodes;
}

Make sure that, if those functions aren't in the same file as your "Main code", that they are visible by means some of sort of include .确保,如果这些功能都没有在同一个文件作为“主代码”,它们是可见的,借助某种形式的include

Edit: As pointed out by @QuentinUK, these functions, or their prototypes at least, need to appear before they are called.编辑:正如@QuentinUK 所指出的,这些函数,或者至少是它们的原型,需要在调用它们之前出现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM