accesing data in class objects (array of pointers to objects)

This is a discussion on accesing data in class objects (array of pointers to objects) within the C++ Programming forums, part of the General Programming Boards category; hey there !!! i hope i'm not bugging you with my "beginner" questions but i'm really stuck here i made ...

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    7

    Angry accesing data in class objects (array of pointers to objects)

    hey there !!! i hope i'm not bugging you with my "beginner" questions but i'm really stuck here

    i made a simple airline-database (school project) where i have 2 classes that read / write themselfes ... in one of my classes i have a passanger ( array of pointers to the objects ) and i need to make couple of functions to deal with data stored inside of objects .... first i need to sort these objects after seet number ( some kind of bubble sort function ), second i have to acces a certain object and delete it from array / memory ....

    well thats about it (simple stuff i know, but hey i have to start somewhere)
    quote: "rom wasn't built in 1 day"

  2. #2
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    I do not fully understand your question. You have an object and want to access its data? You could define some interface functions which other objects can use to get or manipulate that data.

  3. #3
    Registered User kiss_psycho's Avatar
    Join Date
    Feb 2003
    Posts
    49

    Question

    ... in one of my classes i have a passanger ( array of pointers to the objects ) ..
    could yo rephrase that ??
    Definition of Programmer : A red-eyed mumbling mammal capable of conversing with inanimate objects.

    Happy Hunting...
    The Root

  4. #4
    Registered User
    Join Date
    Oct 2003
    Posts
    7
    ok i can see that i didnt describe my problem claerly enough ...

    lets see .... i have lets say 20 objects with different data types ( name, company, number, price and so on ) .... stored in an array (static passanger* arrap[MAX];)

    now i would like to acces the price they payed ( float price ) and add all of them togather ( total_price )


    .... other thing is that i have to make a printable version of my .dat file ( all data stored binary ) .... how to convert bin_to_hex and can i convert the whole file at once ....

    TAKE A LOOK AT MY PROGRAM AND FEEL FREE TO IMPROVE IT !!!
    Last edited by agony; 10-15-2003 at 06:29 PM.

  5. #5
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    So you have an array of MAX objects. Each object is an instance of a class passanger and has members like name, company, number, price etc.

    To access the member price, you could add an interface function to the class passanger which returns the price stored in the object.

    Call this function for all MAX objects and simply add the retrieved values.

    > TAKE A LOOK AT MY PROGRAM AND FEEL FREE TO IMPROVE IT !!!

    I don't see a program here.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. xor linked list
    By adramalech in forum C Programming
    Replies: 23
    Last Post: 10-14-2008, 11:13 AM
  2. static array of function pointers within class
    By Yarbles in forum C++ Programming
    Replies: 6
    Last Post: 11-02-2005, 02:10 PM
  3. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  4. HUGE fps jump
    By DavidP in forum Game Programming
    Replies: 23
    Last Post: 07-01-2004, 11:36 AM
  5. Replies: 4
    Last Post: 09-12-2001, 03:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21