C++ NamespacesLesson 57Free preview
C++ Namespaces
This lesson is part of C++ · All levels
Summary
Namespace is a logical container that groups names such as functions, classes, and variables so as not to clash between program parts. The term std is the C++ built-in namespace for all standard libraries, and we can use it complete with std::cout or using the namespace std. Namespace can also be clustered, so large project code organizations stay neat and easy to search for.
Key points
- Namespace is written namespace Name {...} and its members are called by Name::member.
- Std contains all components of the C++ standard library.
- Using namespace std; cutting down the spelling std:: but risking causing name conflicts.
- The clustered namespace and the use-declaration (using std::cout) are a safer alternative.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.