::类域是什么作用
备战C++二级,结果看到这道题让我蒙了
#include<iostream.h>
int a=10;
class C0
{
public:
C0()
{
a = b= 0;
}
void print()
{
/********found********/
cout<<a<<b<<endl;
}
void fun(int a)
{
/********found********/
this->a += a;
}
void fun2()
{
/********found********/
a += ::a;
}
private:
int a,b;
};
void main()
{
C0 obj;
obj.fun(5);
obj.print();
obj.fun2();
obj.print();
}
要求的结果是要输出50和150,红色的地方,我用了a=a*3,答案却是a += ::a,完全看不明白::的作用,求各位高手解答
[解决办法]
全局或父类
[解决办法]