Sunday, October 10, 2010

Using auto_ptr with Arrays

The following code does not behave nicely:

    {
      auto_ptr<int> pArrayOfInt(new int[10]);
    }

The auto_ptr will do a delete instead of an array delete at the end of its lifetime.

Reference: More Exceptional C++ by Herb Sutter. Addison-Wesley, 2002., p. 176.

No comments:

Post a Comment