Vik*_*oel 1 c++ stl compiler-errors
我的代码出现错误。
vector<vector <int> > v;
deque <TreeNode, int> q;
pair <TreeNode, int> temp;//, node;
temp.first=*root, temp.second=0;
q.push_back(temp); // error is in this line
Run Code Online (Sandbox Code Playgroud)
TreeNode是一种结构,定义为:
struct TreeNode {
int val;
TreeNode *left, *right;
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};
Run Code Online (Sandbox Code Playgroud)
我在编译代码时遇到的错误是: /usr/include/c++/4.6/bits/stl_deque.h:487:61: error: ‘int’ is not a class, struct, or union type
在关注stackoverflow的相关文章之后,我仍然不清楚。有人可以解释一下原因吗?
vector<vector <int> > v;
deque <pair<TreeNode, int> > q; // here is the different
pair <TreeNode, int> temp;//, node;
temp.first=*root, temp.second=0;
q.push_back(temp); // error is in this line
Run Code Online (Sandbox Code Playgroud)
我认为您想将TreeNode和int配对,
deque <pair<TreeNode, int> > q; // here is the different
Run Code Online (Sandbox Code Playgroud)
然后添加到双端队列?
q.push_back(temp);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5481 次 |
| 最近记录: |