C++17 enables writing simple, clearer, and more expressive code. Some of the features introduced in C++17 are:
Namespaces are a very convenient tool to organize and to structure the code base, putting together components like classes and functions that logically belong to the same group.
Let’s consider a hypothetical code base of a video game engine. Here, defined a namespace for the whole game engine, so all the classes and the functions implemented in this Game Engine will be declared under this common namespace. To do more clear definitions you can define another namespace under the global namespace lets say Graphics which is a sub-namespace, now put all classes that perform graphics operations under that namespace and so on.
// Below is the syntax for using
// the nested namespace
namespace Game {
namespace Graphics {
namespace Physics {
class 2D {
..........
};
}
}
}
// Below is the syntax to use the
// nested namespace in one line
namespace Game::Graphics::Physics {
class 2D {
..........
};
}
#c++ #cplusplus #programming-c #c++17