为什么编译器输出以下错误代码:C2143、C2238、C2501

Why the compiler outputs the following error codes: C2143, C2238, C2501

本文关键字:C2143 C2238 C2501 错误代码 编译器 输出 为什么      更新时间:2023-10-16

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;

强烈建议不要使用,尤其是对于头文件。