Passing the address of an object in to a Function
-
Hi there Sorry for the Slopy Subject line!. What i whant to know is the following. I have declared a vector of person Objects
vector(person) people; //in main
I have a confrence classclass conf { public: conf(const string &nm, int d); void set_venue(venue *); void cancel_venue(); private: string conference_name; int duration; venue * pvenue; //pointer to venue class }
I Have added a data member to the conf class which is a vector of pointers to personvector(person *) registered;
and the following member function to register a person who choose to attend a conference.void register_person(????);
So this is what i must do, ok so person objects where added to people //vector(person)people; The person running the program gets to decide who will attend a certian confr thus needing to register this person for the confr. By index how would i pass the address of the specified person object to myregister_person(????);
function and getregister_person(????);
to append this person object to my registration vector(Containing only registered persons). I am knot sure about this->register_person(person & registered)?
needs to recieve the address of a specified(index) person object. Help me:~ Education begins a gentleman, conversation completes him ;) -
Hi there Sorry for the Slopy Subject line!. What i whant to know is the following. I have declared a vector of person Objects
vector(person) people; //in main
I have a confrence classclass conf { public: conf(const string &nm, int d); void set_venue(venue *); void cancel_venue(); private: string conference_name; int duration; venue * pvenue; //pointer to venue class }
I Have added a data member to the conf class which is a vector of pointers to personvector(person *) registered;
and the following member function to register a person who choose to attend a conference.void register_person(????);
So this is what i must do, ok so person objects where added to people //vector(person)people; The person running the program gets to decide who will attend a certian confr thus needing to register this person for the confr. By index how would i pass the address of the specified person object to myregister_person(????);
function and getregister_person(????);
to append this person object to my registration vector(Containing only registered persons). I am knot sure about this->register_person(person & registered)?
needs to recieve the address of a specified(index) person object. Help me:~ Education begins a gentleman, conversation completes him ;)If your prototype for register_person is as you stated "register_person(person & registered", then all you really need to do is do "registered.push_back(®istered)". If you are uncertain of the number of persons, you should be going to the heap for allocation. Then you should be doing "news" on the Person objects and thus your prototype for register_person should be "register_person(person * registered)". You would then just need to do "registered.push_back(person)".