scope resolution operator

H

heng

A::B
I can understand that B is a member of the scope A
But, sometimes I read the expression like ::C, what does this mean when
the scope is absent?
Thanks.
 
V

Victor Bazarov

heng said:
A::B
I can understand that B is a member of the scope A
But, sometimes I read the expression like ::C, what does this mean
when the scope is absent?

It means "global".

V
 
H

Howard

heng said:
A::B
I can understand that B is a member of the scope A
But, sometimes I read the expression like ::C, what does this mean when
the scope is absent?
Thanks.

That's "global scope". (Or is it "global namespace"? I forget.) It's used
to differentiate it from an identically named function or object in the
current scope. For example, there is the global function strcpy(). It is
possible (though perhaps not adviseable) that you have a class (or
namespace) which implements a function also named strcpy(). Using ::strcpy
from inside a function of that class or namespace would mean you're caling
the global strcpy() instead of your class' or namespace's strcpy().

-Howard
 
H

heng

Thanks a lot.
That's "global scope". (Or is it "global namespace"? I forget.) It's used
to differentiate it from an identically named function or object in the
current scope. For example, there is the global function strcpy(). It is
possible (though perhaps not adviseable) that you have a class (or
namespace) which implements a function also named strcpy(). Using ::strcpy
from inside a function of that class or namespace would mean you're caling
the global strcpy() instead of your class' or namespace's strcpy().

-Howard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top