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

后端 未结 2 539
独厮守ぢ
独厮守ぢ 2020-12-12 15:55

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.

2条回答
  •  醉酒成梦
    2020-12-12 16:28

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

    #include 
    
    int main()  
    {
       std::cout<<"Hello world!"<

    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::.

提交回复
热议问题