为什么编译器输出以下错误代码:C2143、C2238、C2501
Why the compiler outputs the following error codes: C2143, C2238, C2501
C2143:语法错误:缺少';'在'<'之前
我可能对C++很生疏,因为我真的不知道这些错误的原因。代码实际上非常简单。(VS2003)
#include <vector>
class store
{
public:
vector<int>storage;
};
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
因为您需要在vector
:前面添加std::
std::vector<int>storage;
vector
类位于std
命名空间内。
或者只是添加
using namespace std;
强烈建议不要使用,尤其是对于头文件。
相关文章:
- cmath抛出错误C2062、C2059、C2143和C2447.cmath包含在矢量文件中
- C++标头错误 C2238 意外标记";"
- 为什么我会收到错误 C2143 语法错误:缺少"*"之前的';'?
- 奇怪的代码抛出编译错误模板< J,int aSize=10> C2143:语法错误:在"<"之前缺少";"
- 从其他类声明类类型变量会给出 C2143 错误(在"*"之前缺少";")
- 简单代码给出C 错误C4430和C2143
- 未知类?C2143 语法错误:缺少"*"之前的";"
- 错误 C2143:语法错误:':'之前缺少','
- 编译错误 C2143:语法错误:'<'之前缺少';'
- 模板类中函数的错误 C4430、C2143 和 C2244
- 错误 C2143:语法错误:'<' C++之前缺少';'
- 为什么编译器输出以下错误代码:C2143、C2238、C2501
- 错误 C2143:语法错误:在"*"之前缺少"{"
- 请求分号时出现令人困惑的错误(错误 C2143)
- 两个语法错误:错误 C2143 语法错误:'*'之前缺少';'
- 可变参数模板 - 错误 C2143:语法错误:'...'之前缺少','
- 错误 C2143:语法错误:':'之前缺少';'
- CS106b 库矢量.cpp错误 C2143:语法错误:'<'之前缺少';'
- C++错误:C4430和C2143错误在不可能的地方
- A C++ issue: Error C2143, Error C2059, Error C2238