Thread: How to use a deconstructor for COM objects?

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    206

    Question How to use a deconstructor for COM objects?

    Hi there,

    I'm having a read through online atm to find a good way of doing this but I thought I'd ask here as well.

    I've made a class that will create a IDXGIFactory4 and a ID3D12Device. The factory part is used (amongst other things) to retrieve data about hardware and checking feature levels.

    The device is the rendering device itself which does the rendering. They're both COM Objects. I'm thinking is it ok to just call the Release() method on them in the class deconstructor?

    Thanks

  2. #2
    Registered User Sir Galahad's Avatar
    Join Date
    Nov 2016
    Location
    The Round Table
    Posts
    277
    Yes, of course, that is in fact the preferable way to go. Much better than calling it manually, which is obviously prone to too few/many invocations.

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    206
    Great. Thanks very much

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Constructor and deconstructor
    By ncode in forum C++ Programming
    Replies: 12
    Last Post: 06-11-2012, 08:09 PM
  2. plz help with deleting class deconstructor.
    By MegaManZZ in forum C++ Programming
    Replies: 6
    Last Post: 08-31-2008, 03:49 PM
  3. Must I always use a deconstructor?
    By markcls in forum C++ Programming
    Replies: 22
    Last Post: 03-25-2007, 03:57 PM
  4. is Recursion ok in a deconstructor?
    By Syneris in forum C++ Programming
    Replies: 14
    Last Post: 01-03-2006, 11:58 PM
  5. Deconstructor throwing exception
    By subdene in forum C++ Programming
    Replies: 13
    Last Post: 06-26-2004, 03:52 AM

Tags for this Thread