Chapter 6

C++ Usage

Publisher Summary

This chapter describes the qualities that make a good API in C++. Many specific C++ style decisions can affect the quality of an API, such as the use of namespaces, operators, friends, and const correctness. A namespace is a logical grouping of unique symbols. It provides a way to avoid naming collisions so that two APIs do not try to define symbols with the same name. Const correctness refers to use of the C++ const keyword to declare a variable or method as immutable. It is a compile-time construct that can be used to maintain the correctness of code that should not modify certain variables. Operator overloading is used to preserve the natural semantics for operators, such as using the + operator to implement ...

Get API Design for C++ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.