a problem about VECTOR---------

From: Joseph (wutongjoe_at_hotmail.com)
Date: 08/11/04


Date: 11 Aug 2004 12:07:32 GMT

I was doing my assignment,but encountered a problem at last step!!!!!!

for easy reading, i ommited lots of other things

//=====================code begin================================
class Buyer{
void start(void);
friend void Buyer_run(Buyer *buyer);
};
void Buyer::start(void){
Buyer_run(this);
};

std::vector<Buyer> buyer_queue;

void Buyer::Buyer_run(Buyer* buyer){
/*========================================
*my problem is here.how can I find out the object which stored in vector
and pointed by *buyer ?
*
*at beginning ,I did it like this,I wrote a function for Buyer class.like
*below:
*
*Buyer* Buyer::return_address(void) {
*return this;
*}
*
*and then use iterator to loop the vector,after that
*I do it like this-->
*if((*iterator).return_address()==(*buyer).return_address())
*if it is true ,i will use buyer_queue.erase();to delete the element.
*
*but the if()statement never return true,why is that?????
*
*to sum up,how can I delete the element which that pointer pointed(by
only knowing/haveing that pointer)?
*============================================
*/
};

void main{

Buyer b=Buyer();
b.start();

}



Relevant Pages

  • VECTOR problem
    ... friend void Buyer_run(Buyer *buyer); ... *to sum up,how can I delete the element which that pointer pointed(by ...
    (comp.lang.cpp)
  • Re: VECTOR problem
    ... > void start; ... // it is an iterator to the buyer in the vector ... that should be 'int main{' ...
    (comp.lang.cpp)
  • Re: a problem about VECTOR---------
    ... Is Buyer_run really a member function of Buyer? ... Above you declared it to be a friend function. ... Don't pass the pointer to a buyer object, ...
    (alt.comp.lang.learn.c-cpp)