I have made an array of objects. I've started by defining a class and making an array containing pointers to that class type. Then I initialized each pointer to NULL.
What I would like to do from here is pass the array to a function that will tell me how many classes are stored in the array. How would I go about doing this? Is it possible to pass an array to a function? Thanks.
Here is my code:
Code:#include <iostream> #include <cstring> using namespace std; class customer{ public: customer( string ); private: string name; }; customer::customer( string x ){ name = x; } int main(){ customer * array[50]; //create array of pointers to customer objects customer fry ( "fry" ); customer bender ( "bender" ); for( int c = 0; c < 50; c++ ){ //initialize to NULL array[c] = NULL; } array[23] = &fry; return 0; }



LinkBack URL
About LinkBacks


