By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,193 Members | 826 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,193 IT Pros & Developers. It's quick & easy.

how to call function for array of object

P: n/a
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 ?
Jul 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"shan" <ss*******@hotmail.com> wrote in message
news:3b*************************@posting.google.co m...
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
Jul 19 '05 #2

P: n/a
"shan" <ss*******@hotmail.com> 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
Jul 19 '05 #3

P: n/a
Faz
"shan" <ss*******@hotmail.com> wrote in message
news:3b*************************@posting.google.co m...
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[i] = nextbook;
}
}

int main(){

addrecords( MAX );

}

This is just a guess..
:)
Faz
Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.