https://rentry.org/PPP2_p77

// Code derived from Stroustrup's PPP2 book
// § 3.8 Types and objects
// -beginning on p 77

#include <iostream>
#include <string>

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

int main()
{
  int    a  = 7;
  int    b  = 9;
  char   c  = 'a';
  double x  = 1.2;
  string s1 = "Hello, World!";
  string s2 = "1.2";

  cout << a << '\n'   // output above variable values to console...
       << b << '\n'   //
       << c << '\n'   //
       << x << '\n'   //
       << s1 << '\n'  //
       << s2 << '\n';
}

build & run:

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

PrevUpNext

Edit
Pub: 21 Jan 2023 04:17 UTC
Edit: 29 Apr 2023 06:29 UTC
Views: 649