#include
class Test { public: Test() { std::cout << “Test constructor” << std::endl; } ~Test() { std::cout << “Test destructor” << std::endl; } void print() { std::cout << “Printing from Test class” << std::endl; } };
int main() {
// Using unique_ptr
std::unique_ptr
// Using shared_ptr
std::shared_ptr<Test> sharedPtr1(new Test);
std::shared_ptr<Test> sharedPtr2 = sharedPtr1;
sharedPtr1->print();
sharedPtr2->print();
return 0;
}