错误:“int”不是类、结构或联合类型
error: ‘int’ is not a class, struct, or union type`
我的代码出错。
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
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
在关注堆栈溢出的相关帖子后,我仍然不清楚。有人可以解释一下可能是什么原因吗?
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
我想你想让树节点,int成对,
deque <pair<TreeNode, int> > q; // here is the different
然后添加到一个双端,
q.push_back(temp);
你对q
的声明是错误的。 通常,deque
只需要一个模板参数 - 要存储在 deque 中的类型。 第二个参数(如果存在(是双端面的分配器类型。
根据这里,deque 的第二个模板参数应该是一个 Alloc 类。
相关文章:
- 特征::矩阵<双精度,1,3> 结构类型函数中的返回类型函数
- <badref> 当使用 CallInst::CreateMalloc 作为结构类型时
- 给定一个C++嵌套的私有结构类型,是否有从文件范围静态函数访问它的策略
- 为什么"具有常量成员的结构"类型的指针不能指向"具有非常量成员的结构"?
- 查找声明为结构类型 C++ 的数组末尾
- C++ - 将结构类型的数组传递给用户定义的函数
- PowerShell 使用结构类型参数调用 C++ DLL 的导出函数
- NTTP 的结构类型:为什么所有成员都必须是公共的?
- 当我尝试访问结构类型时,我收到 std::bad_variant_access 异常
- 承诺可以使用结构类型吗?
- 填充模板化结构类型的结构成员
- 如何为结构类型变量赋值
- 在 c++ 中将结构类型转换为无符号字符*
- 在 c++ 中将一种结构类型分配给另一种类型
- 如何访问在 c++ 中在类内声明的结构类型指针变量?
- 确定输入"conscalc: calc"的类型时出错。不能联合编码器。具有不同字段集的结构类型
- 无法将结构类型的标识符设置为 nullptr;
- 结构类型成员的默认构造函数中的默认参数
- 如何在执行期间终止(或返回)具有结构类型的自动函数
- 在 stl 中迭代结构类型的队列