I am a novice in c++. I have come across the usage of std::unique_ptr and std::shared_ptr in my code
typedef std::unique_ptr<type1> type1Handler;
typedef std::shared_ptr<type2> type2Handler;
I have two questions:
- What is the advantage of using
unique_ptr
andshared_ptr
- What is the prime difference among them?
Possibly an example would be much helpful!