OOPortal 





Building C++ Classes  «Prev  Next»
Lesson 4The scope resolution operator and binary form:
ObjectiveBinary form of the scope resolution operator.
The scope resolution operator's binary form is used to clarify names that are reused within classes.
class widgets { public: void f(); };
class gizmos  { public: void f(); };

void f() { ..... }          //ordinary external f
void widgets::f() { ..... } //f scoped to widgets
void gizmos::f() { ..... }  //f scoped to gizmos
Accessing Namespace Members Directly
Simply use the binary scope resolution operator with the namespace name on the left and the member on the right.

namespace A {
	int x = 1;
	structADT {
		enumColor { RED, WHITE, BLUE };
	};
}
namespace B {
	int x = 2;
	structADT {
		enumColor { GREEN, YELLOW };
	};
}