C++ code test

// Code derived from Stroustrup's PPP2 book
// § 4.6 vector
//  -and beginning on p 118

#include <iostream>
#include <string>
#include <vector>

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

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

  vector<string> philosophers = {"Kant", "Plato", "Hume",
                                 "Kierkegaard"};  // vector of 4 strings

  // output above variable values to console...

  for (int e : v)
    cout << e << '\n';

  cout << '\n';
  //-----------

  for (string philosopher : philosophers)
    cout << philosopher << '\n';
}
Edit
Pub: 16 Jan 2023 01:48 UTC
Views: 300