What is a scope resolution operator?

A scope resolution operator (::), can be used to define the member functions of a class outside the class.

Showing Answers 1 - 16 of 16 Answers

vishnu bobade

  • Sep 8th, 2005
 

shows the scope resolution operator untangling a mess made by using 
the same names for different kinds of entities 
 
base class overridden member function using the scope resolution operator (: :):  
 
The Fundamentals of C++ mt x,y; mt const * p; ... You can use the 
scope resolution operator (::) to specify the desired identifier.

  Was this answer useful?  Yes

Scope resolution:As the name itself indicates,it resolves global scope to local scope
Ex:
int a=10;
int main()
{
a=20;
cout<<::a<<endl;//prints 20
return 0;
}

Useful to convey ownership of class towards a function
Ex:
class ABC{
public:
static void fun()
{
cout<<"ABC"<<endl;
}
};
class XYZ{
public:
static void fun()
{
cout<<"XYZ"<<endl;
}
};
int main()
{
ABC::fun();
XYZ::fun();
return 0;
}

bharat728

  • Jan 13th, 2010
 

It is an operator :: used mainly in class for defining the member funtions and also for accessing the global variables.

  Was this answer useful?  Yes

rajendra chaudhary

  • Oct 31st, 2011
 

It is an operator :: used mainly in class for defining the member functions and also for accessing the global variables.
and it is a eye of c++.

  Was this answer useful?  Yes

keloth1987

  • Nov 7th, 2011
 

You can tell the compiler to use the global identifier rather than the local identifier by prefixing the identifier with ::, the scope resolution operator.

:: identifier
class-name :: identifier
namespace :: identifier
Note: The identifier can be a variable or a function

http://msdn.microsoft.com/en-us/library/b451xz31.aspx

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions