How about defining a class but not make any instance of it?
<p>I am learning some COM code and the following code puzzled me.</p>

<pre><code>    STDMETHODIMP _(ULONG) ComCar::Release() 
    { 
      if(--m_refCount==0)
       {
         delete this; // how could this "suicide" deletion be possible? 
         return 0;
       }
      return m_refCount; 
    } 
</code></pre>

<p>Yes. this is the similar code from <a href="http://stackoverflow.com/questions/200469/what-is-the-difference-between-a-process-and-a-thread">here</a>. And there I askes about <em>how could a memeber method delete its belonging object</em>. Now I am thinking about these 2 scenarios. </p>

<p>1- If I define a class without making an instance of it. Would any data related to this type exist in runtime?</p>

<p>2- If I only make 1 instance of the class and make the very single object commit suicide via the above code. After the object is deleted, where could the object's methods stay? Or am I paying too much attention to the encapsulation illusion?</p>

<p>I am wondering whether class methods are first name-mangled and then stored in the <em>code/text</em> segment of the program without regard to the existence of any object of its type. So the class methods exist as long as you define them.</p>
