Day 18. Creating and Using Namespaces

Namespaces can be used to help you organize your classes. More importantly, namespaces help programmers avoid name clashes when using more than one library.

Today, you will learn

• How functions and classes are resolved by name

• How to create a namespace

• How to use a namespace

• How to use the standard namespace std

Getting Started

Name conflicts have been a source of aggravation to both C and C++ developers. A name clash happens when a duplicate name with matching scope is found in two parts of your program. The most common occurrence can be found in different library packages. For example, a container class library will almost certainly declare and implement a List class. (You’ll learn more about container ...

Get Sams Teach Yourself C++ in 21 Days , Fifth Edition 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.