Results 1 to 2 of 2

Thread: Class/Instance methods and the static keyword...

  1. #1

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205

    Class/Instance methods and the static keyword...

    What do they all mean? My book here is a bit vague on the subject. I'm really interested as to what exactly the static modifier on a method name does.

    I'm creating a small class-inheritance thing, and the examples in the 'inheritance' chapter don't use the static modifier, and doesn't really explain why...

    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  2. #2
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    That is a very good question. I know that when a variable or "class member" is declared as static it's data remains persistent across multiple instances. There seems to be a direct relation between static methods and static members since a static method can only access a static member not an instance member since there is no object being operated on when the object is invoked. As far as i can tell the main benefit of static methods is when they are used in conjunction with static members(when accessing data that remains persistent across multiple instances) as no object instance is needed.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width