[ASIO] destructor called multiple times in test code

OK I think I figured out the problem.
I think I did something stupid. I can't just take an undefined pointer and assign a number to the address it is pointing to.
class print{
int* count;
boost::asio::deadline_timer* t;
static int d_count;
public:
print (boost::asio::io_service& io, boost::asio::deadline_timer* timer)
: t(timer) {
d_count++;
std::cout<<"I'm in constructor: "<<*count<<" Addr of count:"<

Hi! Jose Martinez schrieb:
The copy constructor would then look like this.
print (const print& p): t(p.t), count(p.count){++d_count;}
Remember: the operator = goes along with the copy constructor. Usually you don't modify the "state" from inside the copy ctor. But here it is only some debug statement. But remember: if you do change the state you should think about the operator = , too.
This matches with what Frank was saying about managing the state of operator()() outside of the object.
Yes. :) Frank
participants (2)
-
Frank Birbacher
-
Jose Martinez