错误 C2065:'lO':用于声明向量值的未声明标识符?

error C2065: 'lO' : undeclared identifier for declaring a vector value?

本文关键字:未声明 标识符 用于 C2065 lO 错误 声明 向量      更新时间:2023-10-16

>我不知道我在这里错过了什么。

我应该能够陈述一个向量并在其中输入值,对吧?

#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;
}
错误 1 错误 C2065:"lO":未声明的标识符   c:\users\ck\documents\visual Studio 2013\projects\project1\project1\vectortest.cpp 17 1 Project1错误 2 错误 C2065:"O":未声明的标识符    c:\users\ck\documents\visual Studio 2013\projects\project1\project1\vectortest.cpp 17 1 Project1错误 3 错误 C2065:"O":未声明的标识符    c:\users\ck\documents\visual Studio 2013\projects\project1\project1\vectortest.cpp 21 1 Project1

您使用字母 l (ell) 和 o (oh) 而不是数字 1 和 0。您需要对即时值使用数字。