I am reading a book about auto_ptr, and see the following code:
1 2 3 4 5 6 7 8
auto_ptr<string> films[5] =
{
auto_ptr<string> (new string("Fowl Balls")),
auto_ptr<string> (new string("Duck Walks")),
auto_ptr<string> (new string("Chicken Runs")),
auto_ptr<string> (new string("Turkey Errors")),
auto_ptr<string> (new string("Goose Eggs"))
};
I am wondering if the scope of the auto_ptr is local to the declaration of films array and the destructor will be executed after the declaration of the array, I think I am confused here. need some help to explain the scope and if this declaration can be successful.
Thanks.
does it mean I can not really use the array "film" as after the initialization, the destructor will be called
1 2 3 4 5 6 7 8 9 10 11 12 13
{
auto_ptr<string> films[5] =
{
auto_ptr<string> (new string("Fowl Balls")),
auto_ptr<string> (new string("Duck Walks")),
auto_ptr<string> (new string("Chicken Runs")),
auto_ptr<string> (new string("Turkey Errors")),
auto_ptr<string> (new string("Goose Eggs"))
};
// the objects in the films no longer exist here ??
}
Thanks, it helps to convince me that array {} does not mean scope? Can you give me some more insights about why?
<type> a[num] =
{ #This is not scope??