作用域解析运算符

旧巷老猫 提交于 2019-12-06 08:39:23

作用域运算符“::”

一、(作用域   ):: 《作用域中的某个成员》   =  或   比较?  或者   ->给某个对象。

#if 0
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;
int g_number = 100;

void test01()
{
    int g_number = 200;
    cout << g_number << endl;
    // 打印作用于 全局的变量
    cout << ::g_number << endl;
}

class MyClass{
public:
    const static int a = 10;
};

void test02(){
    cout << MyClass::a << endl;//某个函数作用域的内的东西访问出来
/* 底层实现机制不清楚   */
}

int main(){
    test01();
    system("pause");
    return EXIT_SUCCESS;

}
#endif

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!