listings-Chap18-README.md
Listings of Chap18.docx
This is linked summary of the listings. You can also view it on one page.
- Listing 18.1: With “friend”, you can allow another class access to private members.
- Book: lst-0001-book.cpp
- Godbolt: lst-0001-godb.cpp, https://godbolt.org/z/sTosKfocx
- Listing 18.2: The Tree class has access to private members of Node.
- Book: lst-0002-book.cpp
- Godbolt: lst-0002-godb.cpp, https://godbolt.org/z/oxbcE18TM
- Listing 18.3: When inheriting, you can specify what should become visible.
- Book: lst-0004-book.cpp
- Godbolt: lst-0004-godb.cpp, https://godbolt.org/z/eKbK39nG1
- Listing 18.4: Inherited visibilities, viewed from the outside.
- Book: lst-0005-book.cpp
- Godbolt: lst-0005-godb.cpp, https://godbolt.org/z/61EdcjPn4
- Listing 18.5: Inherited visibilities for further derivations.
- Book: lst-0006-book.cpp
- Godbolt: lst-0006-godb.cpp, https://godbolt.org/z/Pq5aWq8xr
- Listing 18.6: In practice, child classes use privately inherited members indirectly.
- Book: lst-0007-book.cpp
- Godbolt: lst-0007-godb.cpp, https://godbolt.org/z/WYqYe7PoY
- Listing 18.7: A has-a relationship via private inheritance.
- Book: lst-0008-book.cpp
- Godbolt: lst-0008-godb.cpp, https://godbolt.org/z/ETr73T5a9
- Listing 18.8: Has-a relationship using a member.
- Book: lst-0009-book.cpp
- Godbolt: lst-0009-godb.cpp, https://godbolt.org/z/67EjhMf54
- Listing 18.9: A signature class has only pure virtual methods.
- Book: lst-0010-book.cpp
- Godbolt: lst-0010-godb.cpp, https://godbolt.org/z/rW4oTPhrG
- Listing 18.10: A signature class makes a good base class.
- Book: lst-0011-book.cpp
- Godbolt: lst-0011-godb.cpp, https://godbolt.org/z/cevM7nq53
- Listing 18.11: A virtual method with implementation “= 0” is abstract.
- Book: lst-0012-book.cpp
- Godbolt: lst-0012-godb.cpp, https://godbolt.org/z/xWr7axonx
- Listing 18.12: Multiple inheritance means having multiple base classes.
- Book: lst-0014-book.cpp
- Godbolt: lst-0014-godb.cpp, https://godbolt.org/z/xnGTM351G
- Listing 18.13: The clock and calendar combination results in a clock with a calendar.
- Book: lst-0015-book.cpp
- Godbolt: lst-0015-godb.cpp, https://godbolt.org/z/oxoef1nTs
- Listing 18.14: A simple calendar class.
- Book: lst-0017-book.cpp
- Godbolt: lst-0017-godb.cpp, https://godbolt.org/z/56Ec357Tf
- Listing 18.15: The calendar clock is a calendar and a clock.
- Book: lst-0019-book.cpp
- Godbolt: lst-0019-godb.cpp, https://godbolt.org/z/zh5cPG7TK
- Listing 18.16: With multiple inheritance, the value of a pointer can change.
- Book: lst-0023-book.cpp
- Godbolt: lst-0023-godb.cpp, https://godbolt.org/z/oc7jsbrEK
- Listing 18.17: The observer pattern with multiple inheritance.
- Book: lst-0024-book.cpp
- Godbolt: lst-0024-godb.cpp, https://godbolt.org/z/EnE7Y886M
- Listing 18.18: A simple example with virtual inheritance.
- Book: lst-0025-book.cpp
- Godbolt: lst-0025-godb.cpp, https://godbolt.org/z/8jYeYPs7W
- Listing 18.19: Effectively, user() calls a sister method here.
- Book: lst-0026-book.cpp
- Godbolt: lst-0026-godb.cpp, https://godbolt.org/z/s9xnn7c5j
- Listing 18.20: You create a literal data type with a constexpr constructor.
- Book: lst-0029-book.cpp
- Godbolt: lst-0029-godb.cpp, https://godbolt.org/z/Kvfx9Yeox
- Listing 18.21: User-defined literals are especially useful with literal data types.
- Book: lst-0030-book.cpp
- Godbolt: lst-0030-godb.cpp, https://godbolt.org/z/r1vYc7r5j