How should I do to replace the constant pointer with shared_ptr?
How should I do to replace the constant pointer with shared_ptr? int main() { const int *ip = new int(1); *ip = 2; // NG ip = new int(2); // OK } How should I do to achieve the above-mentioned example by using shared_ptr? ---- pegacorn
pegacorn@jcom.home.ne.jp wrote:
How should I do to replace the constant pointer with shared_ptr?
int main() { const int *ip = new int(1); *ip = 2; // NG ip = new int(2); // OK }
How should I do to achieve the above-mentioned example by using shared_ptr?
int main() { boost::shared_ptr<const int> ip(new int(1)); *ip = 2; // NG ip.reset(new int(2)); //OK } Is it really hard to understand the documentation such that the answer isn't obvious? We would really like know so the documentation improves. -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim - grafikrobot/yahoo
Thank you.
From: Rene Rivera
int main() { boost::shared_ptr<const int> ip(new int(1)); *ip = 2; // NG ip.reset(new int(2)); //OK }
There might have been a problem in another place somewhere though I was going to have tested its method. I'm sorry. I had to have tried before post by a simple code like the above-mentioned.
Is it really hard to understand the documentation such that the answer isn't obvious? We would really like know so the documentation improves.
I think that exemplifying in documentation is kinder. ---- pegacorn
participants (2)
-
pegacorn@jcom.home.ne.jp
-
Rene Rivera