【发布时间】: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
【问题讨论】:
-
使用能清楚区分
1、I、l和0、O的字体,您会立即看到区别。一个好的编程字体总是有这些特点 -
@phuclv 我认为您应该将其发布为更好的答案。