namespaces ::

Discussion in 'C++' started by Thomas Ruschival, Dec 1, 2004.

  1. 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
     
    Thomas Ruschival, Dec 1, 2004
    #1
    1. Advertising

  2. Thomas Ruschival wrote:
    > 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.
     
    Jacek Dziedzic, Dec 1, 2004
    #2
    1. Advertising

  3. Thomas Ruschival

    Rolf Magnus Guest

    Thomas Ruschival wrote:

    > 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.
     
    Rolf Magnus, Dec 2, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. valentin tihomirov

    namespaces

    valentin tihomirov, May 24, 2004, in forum: VHDL
    Replies:
    0
    Views:
    619
    valentin tihomirov
    May 24, 2004
  2. Craig Deelsnyder

    Best Practices - solution - namespaces - classes

    Craig Deelsnyder, Aug 3, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    439
    Vincent V
    Aug 4, 2003
  3. Will

    Conflicting namespaces??

    Will, Aug 13, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    1,732
    Chris R. Timmons
    Aug 13, 2003
  4. ravi sankar
    Replies:
    2
    Views:
    396
    abdul bari
    Aug 27, 2003
  5. D. Shane Fowlkes
    Replies:
    1
    Views:
    965
    Tu-Thach
    Jan 13, 2004
Loading...

Share This Page