how to call function for array of object

Discussion in 'C++' started by shan, Nov 6, 2003.

  1. shan

    shan Guest

    I have declared an array of object book.(book[100]).I have also
    defined function outside the class addrecord() which is adding record
    in for loop.Now in main() i want to call addrecord funcion for my
    objects.how can i do so ?
     
    shan, Nov 6, 2003
    #1
    1. Advertising

  2. shan

    Mike Wahler Guest

    "shan" <> wrote in message
    news:...
    > I have declared an array of object book.(book[100]).I have also
    > defined function outside the class addrecord() which is adding record
    > in for loop.Now in main() i want to call addrecord funcion for my
    > objects.how can i do so ?


    Show us your code, otherwise we're only guessing.

    -Mike
     
    Mike Wahler, Nov 6, 2003
    #2
    1. Advertising

  3. "shan" <> wrote...
    > I have declared an array of object book.(book[100]).I have also
    > defined function outside the class addrecord() which is adding record
    > in for loop.Now in main() i want to call addrecord funcion for my
    > objects.how can i do so ?


    Impossible to tell without seeing how 'addrecord' is declared.
    In the future prefer posting C++ to English.

    Victor
     
    Victor Bazarov, Nov 6, 2003
    #3
  4. shan

    Guest

    "shan" <> wrote in message
    news:...
    > I have declared an array of object book.(book[100]).I have also
    > defined function outside the class addrecord() which is adding record
    > in for loop.Now in main() i want to call addrecord funcion for my
    > objects.how can i do so ?


    Maybe you mean something like this :

    class Book { /**/ };

    const int MAX = 100;
    Book book [MAX];

    void addrecords( int COUNT ){

    assert( COUNT <= MAX ); //Sanity check

    for( int i = 0; i<COUNT; ++i ){
    Book nextbook;

    /* Setup nextbook somehow */

    book = nextbook;
    }
    }

    int main(){

    addrecords( MAX );

    }

    This is just a guess..
    :)
    Faz
     
    , Nov 7, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. grbgooglefan
    Replies:
    2
    Views:
    432
    Pascal Bourguignon
    Jan 30, 2008
  2. grbgooglefan
    Replies:
    4
    Views:
    447
    Kenny McCormack
    Jan 30, 2008
  3. grbgooglefan
    Replies:
    0
    Views:
    399
    grbgooglefan
    Jan 30, 2008
  4. Alok
    Replies:
    3
    Views:
    254
  5. THAKUR PRASHANT SINGH

    Class Function call vs Normal Function call

    THAKUR PRASHANT SINGH, Feb 26, 2010, in forum: Ruby
    Replies:
    7
    Views:
    195
    THAKUR PRASHANT SINGH
    Feb 27, 2010
Loading...

Share This Page