The role of "::" symbol in C + +

Source: Internet
Author: User

Domain-Distinguishing symbols in C + + (double colon::) function
A. Identify scope level B. Identifies which class the member belongs to
C. Limits on the scope of the membership D. Indicate scope of scopes

Scope symbol:: The front is typically the class name, followed by the member name of the class, C + + as an example to avoid different classes have names of the same members and scope to distinguish
For example, A,b represents two classes, and members are represented in A,b. So
A::member represents member members in Class A
B::member represents member members in class B

Global scope symbol (double colon) example
#include <stdio.h>

int count = 0; Global variable 0

void Main ()
{

int count = 10; Local variable 10

printf ("Count =%d/n", count);//local variable masks global variable so the output is 10.
{
int count = 20;

printf ("Count =%d/n",:: Count); Scope symbol indicates reference global variable 0
:: Sort
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.