#includeint main() { std::shared_ptr ptr = std::make_shared (10); std::cout << "Size of shared_ptr object: " << sizeof(ptr) << std::endl; return 0; }
#includeThis code creates two shared_ptr objects that reference the same instance of the MyClass class, and then prints the size of the shared_ptr object. The CPP std shared_ptr size is available as a part of the C++ Standard library and does not require any external package library.class MyClass { public: MyClass(int x) : m_x(x) {} ~MyClass() {} private: int m_x; }; int main() { std::shared_ptr ptr1 = std::make_shared (10); std::shared_ptr ptr2 = ptr1; std::cout << "Size of shared_ptr object: " << sizeof(ptr1) << std::endl; return 0; }