1、表示域操作符
class CAnimal
{
public:
int age;
int leg;
};
class CCat : public CAnimal
{
public:
int getLeg();
public:
int m_leg;
};
int CCat::getLeg()
{
return m_leg;
}
2、引用成员函数或者变量
CCat cat;
cat.age = 5;
cat.CAnimal::age = 6;
int getLeg()
{
return 255;
}
int CCat::getLeg()
{
return m_leg;
}
void CCat::printLeg()
{
cout<<CCat::getLeg()<<endl; //调用的是成员函数
return;
}
3、直接用在全局函数前,表示全局函数,如调用API接口函数时。
int getLeg()
{
return 255;
}
int CCat::getLeg()
{
return m_leg;
}
void CCat::printLeg()
{
cout<<::getLeg()<<endl; //调用的全局函数,而非成员函数
return;
}