auto pointer vs smart pointer

Can any one tell what is the difference between auto pointer and smart pointer?

This is been asked in many interviews and I'm not able to answer to this question.

some one suggest a good article for the same??
Smart pointers are objects which own dynamically allocated memory, and automatically free that memory when they go out of scope. std::unique_ptr and std::shared_ptr are examples of some types of smart pointers.


auto_ptr (if that's what they mean) is a kind of smart pointer... similar to unique_ptr in that it has sole ownership of memory, but does not have move semantics and therefore was deprecated in C++11.

Or if they mean auto as in the keyword auto then that's just a normal pointer which may or may not point to dynamically allocated memory, and certainly does not automatically free it.
Last edited on
Topic archived. No new replies allowed.