Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 970863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:52:10+00:00 2026-05-16T02:52:10+00:00

I’m just about done Koenig & Moo’s Accelerated C++ and in Chapters 13 &

  • 0

I’m just about done Koenig & Moo’s Accelerated C++ and in Chapters 13 & 14 they lay out the idea and implementation of a few Handle classes (simple, shared, reference counted).

The classes encpasulate a raw pointer and abstract the allocation / deallocation of dynamic objects away from the client code to avoid all the dangers of raw pointers as well allowing the user to dereference them to access the pointed to object. Basically a ‘safer’ way to interface with raw memory resources.

Are the classes presented in these chapters essentially implementations of smart pointers? Smart pointers are still pretty new to me but from what I understand these Handle classes are performing the same function.

  1. Is there a a distinction between the two or is it just another name for the same thing?
  2. Assuming they’re equivalent in function, in practice would a class like this ever be written from scratch rather than using an already made smart pointer solution?

EDIT

I should add that the classes they develop in these chapters are template classes so they’re not bound to a specific resource, as in they’re not designing a specific FileHandle class for example.

The code in the first code snippet here, 7.1, is pretty much what they’ve got in the chapters I’m referring to.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T02:52:11+00:00Added an answer on May 16, 2026 at 2:52 am

    From your description it sounds like a smart pointer.
    Though personally I would not use the term handle as it is slightly ambiguous (just call a smart pointer a smart pointer).

    Q: Could you write a smart pointer from scratch?
    A: Yes

    Q: Should you write your own smart pointer.
    A: No. Its a lot trickier than you think. Even the description in the book only glossed over the more complex problems. Stick with the standard ones that are provided by reputable libraries.

    Q: Handles what does it mean.
    A: It used to mean a pointer to a pointer. But the term has come ambiguous over the years as the term has been re-used. But you can consider it a pointer to a resource where the resource can be accessed by other methods and in this context their description is sort of valid.

    Q: Should you use smart pointers instead of raw memory.
    A: Never use RAW memory unless absolutely necessary (which is practically never) always encapsulate it in a class that manages it. Whether the class is a smart pointer or another type of object is a good question. std::vector is not considered a smart pointer but it encapsulates a RAW pointer.

    Q: Should you abstract memory management from business logic:
    A: That’s a tricky one and some would may disagree. But I would say always. A class should do one thing. The thing is either resource management OR business logic. combining the two leads too unforeseen complexities.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a JSP page retrieving data and when single or double quotes are
I'm looking for suggestions for debugging... If you view this site in Firefox or
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.