static functions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sreenadh494
    New Member
    • Aug 2007
    • 13

    static functions

    what is the use of static functions, whre it is use,pls give ne detailed infor mation?
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    Originally posted by sreenadh494
    what is the use of static functions, whre it is use,pls give ne detailed infor mation?

    Try to Google on it.
    You will better explanation than me.
    If still you find difficult to understand then come here with your specific Problem.

    Kind regards,
    Dmjpro.

    Comment

    • Meetee
      Recognized Expert Contributor
      • Dec 2006
      • 928

      #3
      Originally posted by sreenadh494
      what is the use of static functions, whre it is use,pls give ne detailed infor mation?
      A static member function can access only static member data, static member functions and data and functions outside the class. It can be called, even when a class is not instantiated.

      Regards

      PS: I think you are preparing for some exams ( by just seeing your questions I think ). I suggest you better search on google. You will get many informative sites discussing these issues. Still doubts, feel free to ask here :)

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by sreenadh494
        what is the use of static functions, whre it is use,pls give ne detailed infor mation?
        For C: a static function is a function that can only be called from other functions
        in the same translation unit (read: source file after everything has been #included).

        For C++: see C, but also a static member function is a function that belongs to
        a class, not to a particular instance (object) thereof. The C-ish usage is a bit
        obsolete nowadays; the anonymous namespace is used instead.

        kind regards,

        Jos

        Comment

        • svlsr2000
          Recognized Expert New Member
          • Feb 2007
          • 181

          #5
          Originally posted by sreenadh494
          what is the use of static functions, whre it is use,pls give ne detailed infor mation?
          There are many uses of static functions and variables in c++. Static variables are used in monostate patterns, in which all the instance of a class needs to refer to same variable.
          Static functions are used in singleton pattern and there is a good article in this forum by weaknessforcats .


          Other uses are passing function pointers to a system call or function written in c.

          Comment

          Working...