Vector Declaration
Before we can work with a vector, we must first declare it. Vector declaration has the following form:
std::vector<type> name;
Where:
type
is the data type of values the vector will contain (e.g., int, double, string)name
is the name of the vector we choose
Declaration examples:
std::vector<int> numbers; // Vector for integers
std::vector<double> temperatures; // Vector for decimal numbers
std::vector<std::string> names; // Vector for texts
Don't forget that to use vectors we must include at the beginning of the program:
#include <vector>
And for working with text (string):
#include <string>
Instructions
Declare a vector of integers (int
) with the name scores
.
Start programming for free
2/10