J
Joseph
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();
}
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();
}