https://rentry.org/PPP2_p78

// Code derived from Stroustrup's PPP2 book
// § 3.9 Type safety
// -beginning on p 78

#include <iostream>

using std::cout;

int main()
{
  double x;            // we “forgot” to initialize:
                       // the value of x is undefined
  double y = x;        // the value of y is undefined
  double z = 2.0 + x;  // the meaning of + and the value of z are undefined

  cout << x << '\n'  // output above variable values to console...
       << y << '\n'  //
       << z << '\n';
}

build & run:

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

PrevUpNext

Edit
Pub: 21 Jan 2023 04:34 UTC
Edit: 29 Apr 2023 06:32 UTC
Views: 571