Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
namespace is a keyword to group functions and classes.
To call something from a certain namespace, write the namespace's name in front, followed by the scope operator, ::.
Functions and classes that are not put into a namespace reside in the global namespace.
The default namespace used is the global namespace. You can change this by using the keyword using.
All STL functions and classes are in the namespace std.
In the example, three versions of the function SayHello reside in different namespaces: loud, soft and the global namespace.
#include <iostream> |
This results in the following screen output:
HELLO WORLD! |
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.