【问题标题】:error C2065: 'lO' : undeclared identifier for declaring a vector value?错误 C2065:“lO”:用于声明向量值的未声明标识符?
【发布时间】:2019-06-01 03:52:11
【问题描述】:

我不知道我在这里缺少什么。

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

#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

【问题讨论】:

  • 使用能清楚区分1Il0O 的字体,您会立即看到区别。一个好的编程字体总是有这些特点
  • @phuclv 我认为您应该将其发布为更好的答案。

标签: c++ vector


【解决方案1】:

您使用字母 l (ell) 和 o (oh) 而不是数字 1 和 0。您需要使用数字来表示立即数。

【讨论】:

  • 那里有一个比这个问题更有趣的故事。
猜你喜欢
  • 2011-02-15
  • 2011-04-16
  • 2011-04-16
  • 2010-12-24
  • 2023-03-04
  • 2011-03-02
  • 2011-12-22
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多