A question about functions

Discussion in 'C++' started by vineoff@gmail.com, Oct 21, 2005.

  1. Guest

    What does static mean in front of function. Like:

    static void f();

    I know what it means when function f is in a class, but when it's not
    in class, what does that mean then?
     
    , Oct 21, 2005
    #1
    1. Advertising

  2. Ferdi Smit Guest

    wrote:
    > What does static mean in front of function. Like:
    >
    > static void f();
    >
    > I know what it means when function f is in a class, but when it's not
    > in class, what does that mean then?
    >


    Generally that it acquires internal linkage. Ie. it becomes "module
    private".

    --
    Regards,

    Ferdi Smit (M.Sc.)
    Email:
    Room: C0.07 Phone: 4229
    INS3 Visualization and 3D Interfaces
    CWI Amsterdam, The Netherlands
     
    Ferdi Smit, Oct 21, 2005
    #2
    1. Advertising

  3. wrote:
    > What does static mean in front of function. Like:
    >
    > static void f();
    >
    > I know what it means when function f is in a class, but when it's not
    > in class, what does that mean then?


    It's been deprecated. The function's name is limited in scope to the file
    in which it's defined. Now, to introduce a function whose name is not
    visible outside its own translation unit, we use anonymous namespaces.

    namespace {
    void f();
    }

    And you should probably define it right there...

    V
     
    Victor Bazarov, Oct 21, 2005
    #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. tshad
    Replies:
    11
    Views:
    842
    tshad
    May 27, 2005
  2. Timothy Wong
    Replies:
    3
    Views:
    430
    Timothy Wong
    May 20, 2004
  3. ILLOGIC
    Replies:
    1
    Views:
    379
    Rob Williscroft
    Jun 1, 2004
  4. Xiangliang Meng
    Replies:
    1
    Views:
    1,652
    Victor Bazarov
    Jun 21, 2004
  5. Steven T. Hatton

    Passing member functions to C functions?

    Steven T. Hatton, Oct 4, 2004, in forum: C++
    Replies:
    7
    Views:
    1,329
    David Hilsee
    Oct 7, 2004
Loading...

Share This Page