June 2025
Intermediate to advanced
1093 pages
33h 24m
English
You can also define a namespace without its own identifier. This then has a special meaning. For the purposes of the next listing, assume that you have several files here.
// https://godbolt.org/z/e3d55zvT8// modul.hpp#include <string>#include <iostream>namespace plant { class Tree { std::string name_; public: explicit Tree(const std::string_view name); void print(std::ostream& os) const; }; std::ostream& operator<<(std::ostream& os, const Tree& arg);}// modul.cpp#include "module.hpp"namespace { // anonymous namespace std::string PREFIX = "TREE:"; void printInfo(std::ostream& os) { os << "Author: Torsten T. Will\n"; }}bool debug = false; // global, no namespacenamespace plant { Tree::Tree(const std::string_view name) ...
Read now
Unlock full access