What is the id / id and unqualified-id / name?

I was wondering if anyone could explain the terms there, since I meet them in many places. I know some basic theory about them, but I'm not sure that I know right or wrong.

So can someone explain these conditions?

+44
c ++
Aug 31 '11 at 13:26
source share
2 answers

A qualified name is a name that has some indication of where it belongs, for example. class specification, namespace specification, etc. An unqualified name is one that is not qualified.

Read James McNellis answer here:

What is a nested name specifier?

Given:

struct A { struct B { void F(); }; }; 
  • A is an unqualified identifier.
  • ::A is a qualified identifier, but does not have a qualifier for nested names.
  • A::B is the qualified identifier, and A:: is the qualifier of nested names.
  • ::A::B is the qualified identifier, and A:: is the qualifier of nested names.
  • A::B::F is an identifier with qualifications and both B:: and A::B:: are nested names.
  • ::A::B::F is a qualified identifier, and B:: and A::B:: are nested names.



+42
Aug 31 '11 at 13:29
source share

The key name is the name that defines the scope. Consider the following sample program, cout and endl are qualified names:

 #include <iostream> int main() { std::cout<<"Hello world!"<<std::endl; return 0; } 

Note that using cout and endl started with std:: . They make them Qualified Names .

If we brought cout and endl to scope using a declaration or directive * (for example, using namespace std; ) and used only cout and endl on their own, they would be unqualified names because they lack std:: .

+12
Aug 31 '11 at 13:30
source share



All Articles