Technical Discussion :: C++
Home > Freshers > Technical Interview Questions > C++
15. What is the scope resolution operator? Explain how does it work in c++?
Answer:
The :: operator links a class name with a member name in order to tell the complier what class the member belongs to. It has another use that is it can allow access to a name in an enclosing scope that is hidden by a local declaration of the same name.
Egname.
Eg:
Void f()
{
int I;
I=10;
………..
……..
}
It may do so by preceding the I with the :: as shown here
Void f()
{
int I;
:: I=10;
……..
……..
}
Asked In :: iGate
The :: operator links a class name with a member name in order to tell the complier what class the member belongs to. It has another use that is it can allow access to a name in an enclosing scope that is hidden by a local declaration of the same name.
Egname.
Eg:
Void f()
{
int I;
I=10;
………..
……..
}
It may do so by preceding the I with the :: as shown here
Void f()
{
int I;
:: I=10;
……..
……..
}
Egname.
Eg:
Void f()
{
int I;
I=10;
………..
……..
}
It may do so by preceding the I with the :: as shown here
Void f()
{
int I;
:: I=10;
……..
……..
}