title: Execution of code in a function after the return statement has been accessed in c++
body: <p>I have the following function:</p>
  
  <pre><code>Class Image {
  
      IplImage* createImage( char* name )
      {
          IplImage* img = cvLoadImage( name );
  
          return img;
  
          ...
      }
  }
  
  int main() {
      IplImage* newimg = createImage( "somepath" );
      return 0;
  }
  </code></pre>
  
  <p>After the <strong>createImage</strong> function is been executed I would like to know if there's a way to execute some code after the return statement has been accessed and the <strong>newimg</strong> has been populated with the contents of the <strong>img</strong> variable.</p>
  
  <p>The above code is an example of what I want to achieve. My main question is: Is there any way I can execute code in a function even after the return statement has been reached?</p>