19 Mar
2009
19 Mar
'09
4:34 p.m.
//possible misuse void foo() { Bar bar; shared_ptr<int> ptr = shared_ptr<int>(new int(10));
bar.set(ptr); } // BOOM!!! => ptr is destroyed before the Bar::~Bar() is called
If you do not program real time soft, it is probably always better to copy sp.
In your example, how would the behavior change, if Bar::set would take the pram by value?