C/C++ Arena

Step 5 of 6

Namespaces and using

A namespace groups names so different libraries don't collide. The standard library lives in std. You can define your own:

namespace game {
    int max_players = 10;
}
std::cout << game::max_players;   // :: is the scope operator

using std::string; lets you write string without the prefix. (You'll often see using namespace std;, which pulls in everything. It's fine for tiny programs but a bad habit in headers and bigger code.)

Your turn: fill in the scope operators and the using-declaration.

Previous: bool, auto and range-for Next: Whole lines with getline