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