how to call function for array of object

S

shan

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 ?
 
M

Mike Wahler

shan said:
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
 
V

Victor Bazarov

shan said:
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
 
F

Faz

shan said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top