错误C2065:“ lO”:用于声明矢量值的未声明标识符?

时间:2019-01-06 02:38:52

标签: c++ vector

我不知道我在这里想念什么。

我应该能够只声明一个向量并将值放入其中,对吧?

#include <iostream>
#include <string>
#include <vector>

using std::cout;
using std::cin;
using std::endl;
using std::string;
using namespace std;

int main()
{
    cout << "Creating a lO element vector to hold scores.\n";
    vector<int> scores(lO, O); //initialize all l0 elements to O
    cout << "Vector size is :" << scores.size() << endl;
    cout << "Vector capacity is:" << scores.capacity() << endl;
    cout << "Adding a score.\n";
    scores.push_back(O); //memory is reallocated to accommodate growth
    cout << "Vector size is :" << scores.size() << endl;
    cout << "Vector capacity is:" << scores.capacity() << endl;
    return 0;
}
Error   1   error C2065: 'lO' : undeclared identifier    
c:\users\ck\documents\visual Studio 2013\projects\project1\project1\vectortest.cpp  17  1   Project1
Error   2   error C2065: 'O' : undeclared identifier     
c:\users\ck\documents\visual Studio 2013\projects\project1\project1\vectortest.cpp  17  1   Project1
Error   3   error C2065: 'O' : undeclared identifier     
c:\users\ck\documents\visual Studio 2013\projects\project1\project1\vectortest.cpp  21  1   Project1

1 个答案:

答案 0 :(得分:0)

您使用的是字母l(ell)和o(oh),而不是数字1和0。您需要使用数字作为立即数。