1.

Refer To A Name Of Class Or Function That Is Defined Within A Namespace?

Answer»

Answer :There are two WAYS in which we can refer to a name of class or function that is defined within a namespace: USING scope RESOLUTION operator through the using keyword. This is shown in following example: namespace name1 { class sample1 { // code } ; } namespace name2 { class sample2 { // code } ; } using namespace name2 ; VOID main( ) { name1::sample1 s1 ; sample2 s2 ; } Here, class sample1 is REFERRED using the scope resolution operator. On the other hand we can directly refer to class sample2 because of the statement using namespace name2 ; the using keyword declares all the names in the namespace to be in the current scope. So we can use the names without any qualifiers.



Discussion

No Comment Found