Table of Contents

Search

  1. Preface
  2. Introduction
  3. Program Design
  4. SSA-NAME3 Functions
  5. Language Specific Guidelines
  6. Controls
  7. Advanced Controls
  8. Address Standardization
  9. ASM Workbench

SSA-NAME3 API Reference Guide

SSA-NAME3 API Reference Guide

Use of Destructors

Use of Destructors

C++, unlike JAVA and C# has destructors that are called whenever an instance of an object goes out of scope (or the delete operator is called on that object). This allows for any calls to resource releasing type functions (
ssan3_close
and
ssan3_disconnect
for example) to be made from an appropriate ’destructor’. Of course as soon as a class has an explicit destructor it must also have an explicit ’copy constructor’ and ’assignment operator’. Once objects start getting copied around, it is easy to end up with two instance of an object with identical socket handles. When one of these objects goes out of scope the destructor is called and the socket connection is closed. When the second object tries to use the socket connection a conflict arises. Two ways to avoid this situation are as follows:
  • To use some type of reference counting in the class so that the socket connection is only closed when the last objet which used it goes out of scope.
  • Secondly, make the copy constructor and assignment operator for the class ’private’ (and without a body). Then any attempts to make copies of these objects will cause a compilation error which it may then be possible to code around.

0 COMMENTS

We’d like to hear from you!