a problem about VECTOR---------
From: Joseph (wutongjoe_at_hotmail.com)
Date: 08/11/04
- Next message: Maya: "Re: Compiling C as C++"
- Previous message: Maya: "Re: Catching exceptions thrown from base class constructors?"
- Next in thread: Karl Heinz Buchegger: "Re: a problem about VECTOR---------"
- Reply: Karl Heinz Buchegger: "Re: a problem about VECTOR---------"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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();
}
- Next message: Maya: "Re: Compiling C as C++"
- Previous message: Maya: "Re: Catching exceptions thrown from base class constructors?"
- Next in thread: Karl Heinz Buchegger: "Re: a problem about VECTOR---------"
- Reply: Karl Heinz Buchegger: "Re: a problem about VECTOR---------"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|