https://rentry.org/PPP2_p119b

// Code derived from Stroustrup's PPP2 book
// § 4.6.1 Traversing a vector
//  -and beginning on p 119

#include <iostream>
#include <vector>

using std::cout;
using std::vector;

int main()
{
  vector<int> v = {5, 7, 9, 4, 6, 8};

  for (unsigned int i = 0; i < v.size(); ++i)
    cout << v[i] << '\n';
}

build & run:

g++ -std=c++20 -O2 -Wall -pedantic ./ch_04/main_p119b.cpp && ./a.out

PrevUpNext

Edit
Pub: 08 Feb 2023 01:09 UTC
Edit: 29 Apr 2023 08:37 UTC
Views: 408