从C++ 的参考资料 namespace 及 class内的static member 才可以用 "::"
但是下列的code 上色部分却可使用 且指向class base的member function
想请问 "::"的使用规则?
#include <iostream>
using namespace std;
class MyC
{
public:
int getValue() { return 1; } // static member function
};
class MyC1:public MyC
{
public:
int getValue() { return 2; } // static member function
};
int main()
{
MyC c;
MyC1 c1;
MyC1 *p;
p=&c1;
cout<<p->getValue()<<endl;
cout<<p->MyC::getValue()<<endl; //why :: could be used here
return 0;
}