Apache resigns from the Java Community Process executive committee
Apache resigns from the Java Community Process executive committee
Posted Dec 14, 2010 5:05 UTC (Tue) by cmccabe (guest, #60281)In reply to: Apache resigns from the Java Community Process executive committee by HelloWorld
Parent article: Apache resigns from the Java Community Process executive committee
There is only one way to avoid the problem: experience. You must not allow people to use anonymous shared_ptr objects; it's too dangerous.
Here's another traditional memory leak, which I don't think you'll need teh Google to spot:
> #include <iostream>
> #include <tr1/memory>
>
> using std::tr1::shared_ptr;
> using std::cout;
>
> class Foo {
> public:
> Foo() {}
> };
>
> class Bar : public Foo {
> public:
> Bar(int b_) : b(b_) { }
> private:
> int b;
> };
>
> int main(void) {
> Foo *my_foo = new Bar(5);
> shared_ptr<Foo> my_shared_foo(my_foo);
>
> return 0;
> }
