Reputation: 1
Is it possible to add an object to a namespace in c++ so i can access its variables simply by writing the name of the variable and without the need of writing the name of the object followed by dot and then the variable name?
Upvotes: 0
Views: 297
Reputation: 234715
Dot? In C++, namespaces are descriminated using the scope resolution operator ::
; for example std::string
tells you that the string
class is in std
.
if you write the statement using namespace /*your namespace here*/
then you can drop the explicit namespace reference and the ::
.
Upvotes: 2