【C++总结】C++的域运算符'::'

来源:互联网 发布:淘宝星期四官换机知乎 编辑:程序博客网 时间:2024/05/21 20:26

第一个作用

可以访问全局变量

int num = 10;int main() {    int num = 5;    cout << num << endl;//5    cout << ::num << endl;//10}

实现类中的成员函数,或者类函数的时候

Person::Person(string name, int age) {    this->name = name;    this->age = age;}Person::~Person() {}string Person::getName() {}
0 0
原创粉丝点击