| |
GeekInterview.com > Interview Questions > Programming > C++
| Print | |
| Question: What is a scope resolution operator?
Answer: A scope resolution operator (::), can be used to define the member functions of a class outside the class. |
| December 12, 2008 12:24:52 |
#2 |
| burraganesh |
Member Since: December 2008 Total Comments: 20 |
RE: What is a scope resolution operator? |
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; } |
| |
Back To Question | |