https://rentry.org/PPP2_p265a

// Code derived from Stroustrup's PPP2 book
// § 8.3 Header files
//  -and beginning on p 265

//------------------------------------------------------------------------------
// as filename: f.h

int f(int);

//------------------------------------------------------------------------------
// as filename: f.cpp

// #include "f.h"

int f(int n) { return n; }

//------------------------------------------------------------------------------
// as filename: main.cpp  (aka "user.cpp" in book)

// #include "f.h"

int g(int i) { return f(i); }

int main() { return g(0); }

build & run:

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

PrevUpNext

Edit
Pub: 04 Apr 2023 14:21 UTC
Edit: 02 May 2023 22:17 UTC
Views: 615