W
Wayne Shu
see the following code from the book C++ Templates The Complete Guide
#include <iostream>
int C; // (1)
class C // (2)
{
private:
int i[2];
public:
static int f(){
return sizeof(C);
};
};
int f()
{
return sizeof(C);
}
int main()
{
std::cout << "C::f() " << C::f() << ","
<< "::f() " << ::f() << std::endl;
return 0;
}
why the result of the program is
C::f() 8,::f() 4
why the two names C are not ambiguous.
if aren't ambiguous ,why the name C(2) doesn't hide the name C(1).
why in function f(), the C refer to the C(1).
#include <iostream>
int C; // (1)
class C // (2)
{
private:
int i[2];
public:
static int f(){
return sizeof(C);
};
};
int f()
{
return sizeof(C);
}
int main()
{
std::cout << "C::f() " << C::f() << ","
<< "::f() " << ::f() << std::endl;
return 0;
}
why the result of the program is
C::f() 8,::f() 4
why the two names C are not ambiguous.
if aren't ambiguous ,why the name C(2) doesn't hide the name C(1).
why in function f(), the C refer to the C(1).