Reputation: 105
I found the following class declaration hard to understand:
class App::Impl
Is the class name now App::Impl? What does the scope operator ::
do in the class name?
Upvotes: 0
Views: 1394
Reputation: 111
The Scope Resolution Operator(::) is used to identify and specify the context to which an identifier refers. So here App
refers to the namespace to which the class Impl
belongs to. We can have different classes having same name by sub-scoping them in different namespaces. In such situations we need to specify the namespace of the class.
namespace X{
class Name {};
}
namespace Y{
class Name {};
}
Here we can use X::Name
and Y::Name
Upvotes: 3
Reputation:
In C++ ::
is the Scope Resolution Operator. It is used to tell the compiler what namespace or class something belongs to.
In this case, App::Impl
tells the compiler you are talking about the Impl
that belongs to App
.
Upvotes: 1
Reputation: 371
App is the NameSpace of that class you called Impl that can be defined in more NameSpaces with differences .
Upvotes: 1