shared_ptr_example2.cpp 653 B

12345678910111213141516171819202122
  1. // Boost shared_ptr_example2 implementation file -----------------------------//
  2. // Copyright Beman Dawes 2001. Distributed under the Boost
  3. // Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org/libs/smart_ptr for documentation.
  6. #include "shared_ptr_example2.hpp"
  7. #include <iostream>
  8. class example::implementation
  9. {
  10. public:
  11. ~implementation() { std::cout << "destroying implementation\n"; }
  12. };
  13. example::example() : _imp( new implementation ) {}
  14. void example::do_something()
  15. { std::cout << "use_count() is " << _imp.use_count() << "\n"; }