Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows API
  4. Question about (CX?) destructor?

Question about (CX?) destructor?

Scheduled Pinned Locked Moved Windows API
questiongraphicsgame-devhelplounge
3 Posts 3 Posters 11 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Super Lloyd
    wrote on last edited by
    #1

    In the DirectX metro sample one can find a class named DirectXBase with roughly this header:

    ref class DirectXBase abstract
    {
    public:
    DirectXBase();

    virtual void Render() = 0;
    virtual void Present();
    // ....
    

    protected:

    Microsoft::WRL::ComPtr           m\_d2dFactory;
    Microsoft::WRL::ComPtr             m\_d2dDevice;
    Microsoft::WRL::ComPtr      m\_d2dContext;
    Microsoft::WRL::ComPtr            m\_d2dTargetBitmap;
    // ....
    

    };

    What I find strange is that there is no destructor! What about all those ComPtr? are they automatically set to null because it's a ref class? is it a bug?

    A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station.... _________________________________________________________ My programs never have bugs, they just develop random features.

    A A 2 Replies Last reply
    0
    • S Super Lloyd

      In the DirectX metro sample one can find a class named DirectXBase with roughly this header:

      ref class DirectXBase abstract
      {
      public:
      DirectXBase();

      virtual void Render() = 0;
      virtual void Present();
      // ....
      

      protected:

      Microsoft::WRL::ComPtr           m\_d2dFactory;
      Microsoft::WRL::ComPtr             m\_d2dDevice;
      Microsoft::WRL::ComPtr      m\_d2dContext;
      Microsoft::WRL::ComPtr            m\_d2dTargetBitmap;
      // ....
      

      };

      What I find strange is that there is no destructor! What about all those ComPtr? are they automatically set to null because it's a ref class? is it a bug?

      A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station.... _________________________________________________________ My programs never have bugs, they just develop random features.

      A Offline
      A Offline
      Albert Holguin
      wrote on last edited by
      #2

      Well, it's an abstract class... and all those are pointers. So if they were never allocated, they don't need to be destroyed.

      1 Reply Last reply
      0
      • S Super Lloyd

        In the DirectX metro sample one can find a class named DirectXBase with roughly this header:

        ref class DirectXBase abstract
        {
        public:
        DirectXBase();

        virtual void Render() = 0;
        virtual void Present();
        // ....
        

        protected:

        Microsoft::WRL::ComPtr           m\_d2dFactory;
        Microsoft::WRL::ComPtr             m\_d2dDevice;
        Microsoft::WRL::ComPtr      m\_d2dContext;
        Microsoft::WRL::ComPtr            m\_d2dTargetBitmap;
        // ....
        

        };

        What I find strange is that there is no destructor! What about all those ComPtr? are they automatically set to null because it's a ref class? is it a bug?

        A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station.... _________________________________________________________ My programs never have bugs, they just develop random features.

        A Offline
        A Offline
        Aescleal
        wrote on last edited by
        #3

        If whatever god foresaken language you're using works like C++ then the compiler will generate a default constructor for you. This default destructor will call the destructors for the data members for you (in the reverse order they were constructed). If it doesn't work like C++ then all bets are off :-). Cheers, Ash

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups