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

  • SEARCH
  • Home
  • 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 7595531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:41:39+00:00 2026-05-30T21:41:39+00:00

Some classes of project I’m working on look like this class ATLCOMCLASS<CComObjectRootEx<ATLCOMCLASS> > {

  • 0

Some classes of project I’m working on look like this

class ATLCOMCLASS<CComObjectRootEx<ATLCOMCLASS> >
{
  ISomeInterfacePtr p;
  /*some stuff*/
  void FinalRelease()
  {
    p = NULL;
  }
}

ISomeInterfacePtr is defined by _COM_SMARTPTR_TYPEDEF. I don’t understand why does it need to explicitly do p = NULL which means p->Release(), if this operation will be conducted in ATLCOMCLASS dtor automatically.

Could you exaplain me, please?

  • 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-30T21:41:40+00:00Added an answer on May 30, 2026 at 9:41 pm

    Technically, it doesn’t have to do p = NULL at that point in the code, or explicitly at any point, because the destructor will release the smart pointer as you noted. However, explicitly releasing it gives you finer control over when it happens, which may be of use.

    Depending on the requirements of ISomeInterface, the program, and other factors, releasing p before this is destroyed might satisfy some program condition. In particular, if FinalRelease() is called by another method and not the dtor, then the cleanup is happening somewhere else and likely has a very different trigger. It could also be cleaned up and then some resources recreated in a sort of reset, or any number of other sequences.

    To figure out exactly why this is useful, assuming it’s not a mistake, you’ll need to work back up the possible program flow and see what’s going on.

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

Sidebar

Related Questions

I have some classes layed out like this class A { public virtual void
In some classes I see a call to a function is like: $this->ClearError(); When
i've made a Class Library project for Asp.Net applications, consisting in some classes plus
I auto-generated some classes using xsd.exe for a project I am working on. I
Inside a maven project, I would like to use some classes that were already
I want to add some classes to a CodeIgniter project that aren't models, views,
For my current project I want to be able to load some classes from
I need to use some classes inside the app_code folder of a website project
In NetBeans 6.7.1, I had a Java project in which I renamed some classes.
Some classes, like exceptions or templates, only need the header file (.h), often there

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.