Electron microscopy
 
Problems When Passing Objects in C++
- Practical Electron Microscopy and Database -
- An Online Book -
Microanalysis | EM Book                                                                                   http://www.globalsino.com/EM/        


=================================================================================

 

In CLASS, even though objects are passed to functions by means of the normal call-by-value parameter-passing mechanism. In principle, this method can protect and insulate the calling argument; however, it is still possible for a side effect to occur that may affect, or even damage, the object used as an argument. For instance, if an object used as an argument allocates dynamic memory and frees that memory when it is destroyed, its local copy inside the function will free the same memory when the destructor is called. This can be a problem because the original object is still using the memory. In this situation, the original object will be damaged and effectively useless.

 

 

 

 

 

 

 

 

 

 

=================================================================================