Results 1 to 3 of 3

Thread: accessibility

  1. #1

    Thread Starter
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Resolved accessibility

    Let's say I have two classes, Class1, and Class2.....
    Class2 creates and instance of Class1 and calls one of it's methods like this:

    Code:
    Class 2 { 
                         Class1 c1 =new Class1(); c1.myMethod();
           }

    Now, that would work...But, could you have just the class variable instead of the class instance variable like this:

    Code:
    Class 2 {
                   Class1.myMethod(); 
               }

    Or would that not work...What I was thinking, was in order to do that, Class1 would have to be static..Right?

    <Moderator added green check mark>
    Last edited by NoteMe; Feb 21st, 2005 at 09:17 AM.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: accessibility

    myMethod in Class1 would have to be static.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: accessibility

    Thanks CB..I guess I was sort of on the right track.

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