https://rentry.org/PPP2_p295 ⎗ ✓ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31// Code derived from Stroustrup's PPP2 book // § 8.7 Namespaces // -and beginning on p 295 // clang-format off namespace Graph_lib { struct Color { /* ... */ }; struct Shape { /* ... */ }; struct Line : Shape { /* ... */ }; struct Function : Shape { /* ... */ }; struct Text : Shape { /* ... */ }; // ... int gui_main() { /* ... */ return 0; } } // namespace Graph_lib namespace TextLib { class Text { /* ... */ }; class Glyph { /* ... */ }; class Line { /* ... */ }; // ... } // namespace TextLib // clang-format on int main() { return Graph_lib::gui_main(); } build & run: g++ -std=c++20 -O2 -Wall -pedantic ./ch_08/main_p295.cpp && ./a.out sauce: Bjarne Stroustrup's PPP2 textbook /robowaifu/'s official C++ learning textbook thread Prev • Up • Next