The only reason I'd worry about is that Dog is now allocated on the stack, rather than the heap. So if Dog is megabytes in size, you may have a problem,
如果您确实需要使用新建/删除路线,请注意异常。正因为如此,您应该使用 auto _ ptr 或者其中一种升级智能指针类型来管理对象生存期。
You might want to consider using a shared_ptr (or one of its variants) from the standard library if you do want to allocate on the heap. That'll handle doing the delete for you once all references to the shared_ptr have gone out of existance.