June 2017
Intermediate to advanced
532 pages
12h 59m
English
In this section, we will use the two different ways to access an std::vector, and then see how we can utilize them to write safer programs without decreasing readability.
#include <iostream> #include <vector> using namespace std;
int main() { const size_t container_size {1000}; vector<int> v (container_size, 123);
cout << "Out of range element value: " << v[container_size + 10] << '\n';
cout << "Out of range element value: " << v.at(container_size + 10) ...Read now
Unlock full access