https://rentry.org/PPP2_p162b

// Code derived from Stroustrup's PPP2 book
// § 5.9.1 Practical debug advice
//  -and beginning on p 162

#include <iostream>

using std::cerr;

int my_fct(int a, double d)
{
  int res = 0;
  cerr << "my_fct(" << a << "," << d << ")\n";

  // . . . misbehaving code here . . .

  cerr << "my_fct() returns " << res << '\n';
  return res;
}

int main() { my_fct(1, 2.2); }

build & run:

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

PrevUpNext

Edit
Pub: 25 Feb 2023 11:53 UTC
Edit: 29 Apr 2023 10:04 UTC
Views: 404