[ACCEPTED]-Accessing Parent Namespace in C++-namespaces
Accepted answer
You need to specify the namespace, in this 6 case the global one:
class criterion : public ::criterion
Note that c++ doesn't 5 specify any means of navigating namespaces 4 as if they were a tree. For example, you 3 can't specify the the "parent" namespace 2 using ".." or any other shorthand - you 1 have to use its name.
Start with "::"
For example
class criterion : public ::criterion {};
0
Simplified basic C++ namespace rules are:
- You can access anything in parent namespace path without specifying namespace.
- You can access anything in child namespace path by specifying only relative path.
- Everything else requires full namespace specifications.
0
This compiles for me, basically just explicitly 2 show in what namespace the parent class 1 is:
class A
{};
namespace B {
class A : public ::A
{};
namespace C {
class A : public B::A
{};
}
};
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.