Results 1 to 2 of 2

Thread: more class problems!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 1999
    Location
    East Ballina,NSW,Australia
    Posts
    121

    Exclamation more class problems!

    Hi there,

    can someone tell me how i can access data from one class while i'm in another for. i can do it with normal classes but i can't do it with arrarys of classes properly, here's a sample below...

    elevator::close_doors
    {
    person[i].waiting = 1;
    }

    It won't let me do it, waiting is a public booleen in the person class.

    is there a possible way to do this?

    Thanks.

    Regards,

    Smithy.

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    If person is a class, then obviously it will only work if waiting is a public static variable - you would need to access a member variable on an object to even give an array expression any meaning.

    Actually it's not at all good programming practice to access global variables from within classes, if you want to access an array of person, from within your another class, make sure either
    a. The array is contained in that class
    b. A reference to that array is
    c. The array reference is passed to the function.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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