include smart pointer c++ code example
Example 1: c++ make shared_ptr
#include <memory>
std::shared_ptr<int> foo = std::make_shared<int> (10);
Example 2: c++ smartpointer
#include <memory>
void my_func()
{
std::unique_ptr<int> valuePtr(new int(15));
int x = 45;
// ...
if (x == 45)
return; // no memory leak anymore!
// ...
}
int main()
{
}