https://rentry.org/PPP2_p149a

// Code derived from Stroustrup's PPP2 book
// § 5.6.2 Range errors
//  -and beginning on p 149

#include <iostream>
#include <vector>

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

int main()
{
  vector<int> v(5);

  int x = v[5];

  cout << x << '\n';
}

build & run:

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

PrevUpNext

Edit
Pub: 23 Feb 2023 06:23 UTC
Edit: 29 Apr 2023 09:27 UTC
Views: 603