namespaces ::

  • Thread starter Thomas Ruschival
  • Start date
T

Thomas Ruschival

Hi,
for now I know what namespaces are and a little how they are used and imported.
Am I right in the assumption that everything defined in the STL is in namespace std? (like vector and string etc.)

One thing is still unclear, I came across it in some sample code for network socket programming:
the author uses just two colons in front of a c-Function while he has a methos in a c++ class that has the same name. in the own method Socket::bind() the has a statement ::bind().

what do these 2 colons refer to?

T.i.a.
Thomas
 
J

Jacek Dziedzic

Thomas said:
One thing is still unclear, I came across it in some sample code for network socket programming:
the author uses just two colons in front of a c-Function while he has a methos in a c++ class that has the same name. in the own method Socket::bind() the has a statement ::bind().

what do these 2 colons refer to?

To the global bind().

HTH,
- J.
 
R

Rolf Magnus

Thomas said:
Hi,
for now I know what namespaces are and a little how they are used and
imported. Am I right in the assumption that everything defined in the STL
is in namespace std? (like vector and string etc.)

Well, everything that can be. There are some preprocessor macros, and the
preprocessor doesn't support namespaces.
One thing is still unclear, I came across it in some sample code for
network socket programming: the author uses just two colons in front of a
c-Function while he has a methos in a c++ class that has the same name. in
the own method Socket::bind() the has a statement ::bind().

what do these 2 colons refer to?

It means that the bind() function is looked for in the global namespace and
not in the Socket class.
 

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

Similar Threads


Members online

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top