存储结构向量

发布于 2024-12-20 15:03:58 字数 256 浏览 3 评论 0原文

struct node{
double dat;
char oper;
node *left,*right;
}
vector <node> data;
vector <node> op;

在这里,我声明了我的节点结构并尝试存储节点向量。这是一个简单的二叉树节点。 当我声明向量时发生错误。它说:“数据之前的声明符无效”,当我声明 op 时也是如此。 您能解释一下我的错在哪里以及如何获取结构向量吗? :-) 谢谢!!!

struct node{
double dat;
char oper;
node *left,*right;
}
vector <node> data;
vector <node> op;

Here I declare my node struct and Trying to store a vector of nodes. It's a simple Binary Tree node.
ERROR occurs when I declare vectors. It says: "invalid declarator before data" and same when I declare op.
Would you please Explain where's my fault and how to take a vector of structs?
:-) THANKS!!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

烂人 2024-12-27 15:03:58

也许你错过了结构减速后的分号。

struct node{
double dat;
char oper;
node *left,*right;
};

perhaps you missed the semicolon after the structure decleration.

struct node{
double dat;
char oper;
node *left,*right;
};
梦里°也失望 2024-12-27 15:03:58
struct node{
double dat;
char oper;
node *left,*right;
};

请注意;

struct node{
double dat;
char oper;
node *left,*right;
};

note the ;

み零 2024-12-27 15:03:58

可能在其他地方您的代码可能存在问题。相同的代码(具有正确的标头、结构声明后的半列等)可以在 gcc 和 xlc++ (AIX) 中编译。

#include <iostream>
#include <vector>
using namespace std;

struct node{
    double dat;
    char oper;
    node *left,*right;
};

int main()
{
    vector <node> data;
    vector <node> op;
}

Probably somewhere else there might be a problem in your code. Same code (with proper headers, a semi-column after struct declaration etc) compiles for me in gcc and xlc++ (AIX).

#include <iostream>
#include <vector>
using namespace std;

struct node{
    double dat;
    char oper;
    node *left,*right;
};

int main()
{
    vector <node> data;
    vector <node> op;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文