Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are qualified-id/name and unqualified-id/name?

Tags:

c++

I was wondering if someone could explain there terms since I encounter them in many places. I know some basic theory about them but not sure what I know is right or wrong.

So can any one please explain these terms?

like image 340
M3taSpl0it Avatar asked Aug 31 '11 13:08

M3taSpl0it


People also ask

What is a qualified ID?

A qualified identifier is a program element (interface, type, variable, name space, etc.) that has a fully qualified name. A fully qualified name is the complete hierarchical path of an identifier, starting from its global name space.

What does expected unqualified ID mean?

The expected unqualified id error shows up due to mistakes in the syntax. As there can be various situations for syntax errors, you'll need to carefully check your code to correct them. Also, this post points toward some common mistakes that lead to the same error.

What is qualified name in C++?

Modules (C++20) [edit] A qualified name is a name that appears on the right hand side of the scope resolution operator :: (see also qualified identifiers).


2 Answers

A qualified name is one that has some sort of indication of where it belongs, e.g. a class specification, namespace specification, etc. An unqualified name is one that isn't qualified.

Read James McNellis' answer here:

What is a nested name specifier?

Given:

struct  A {     struct B {         void F();     }; }; 
  • A is an unqualified-id.
  • ::A is a qualified-id but has no nested-name-specifier.
  • A::B is a qualified-id and A:: is a nested-name-specifier.
  • ::A::B is a qualified-id and A:: is a nested-name-specifier.
  • A::B::F is a qualified-id and both B:: and A::B:: are nested-name-specifiers.
  • ::A::B::F is a qualified-id and both B:: and A::B:: are nested-name-specifiers.

like image 128
Sadique Avatar answered Sep 29 '22 23:09

Sadique


A qualified name is one that specifies a scope.
Consider the following sample program, the references to cout and endl are qualified names:

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

Notice that the use of cout and endl began with std::. These make them Qualified names.

If we brought cout and endl into scope by a using declaration or directive*(such as using namespace std;), and used just cout and endl just by themselves , they would have been unqualified names, because they would lack the std::.

like image 24
Alok Save Avatar answered Sep 29 '22 21:09

Alok Save