#include#include "cppcheckable_ptr.hpp" int main() { // create a cppcheckable Ptr object cppcheckable_ptr p(new int(10)); // get the value of the pointed-to object std::cout << *p << std::endl; // should output 10 // change the value of the pointed-to object *p = 20; std::cout << *p << std::endl; // should output 20 return 0; }
#includeIn this example, we pass a cppcheckable_ptr object to a function that increments the value it points to by 1. This shows how cppcheckable Ptr can be used as a function parameter, allowing for safe memory management even in complex code. Package Library: BoostSharedPtr library.#include "cppcheckable_ptr.hpp" void add_one(cppcheckable_ptr p) { *p += 1; } int main() { cppcheckable_ptr p(new int(10)); add_one(p); std::cout << *p << std::endl; // should output 11 return 0; }