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

时间:2012-08-30 09:48:06

标签: c++ compiler-errors

C2143:语法错误:缺少';'在'<'

之前

我可能在C ++中很生疏,因为我真的不知道这些错误的原因。 代码实际上非常简单。 (VS2003)

#include <vector>

class store
{
public:
    vector<int>storage;
};

int _tmain(int argc, _TCHAR* argv[])
{
    return 0;
}

1 个答案:

答案 0 :(得分:3)

因为您需要在std::前面添加vector

std::vector<int>storage;

vector类位于std命名空间内。


或者只是添加

using namespace std;
建议使用高度不,尤其是对于头文件。