[Insight-developers] Copy constructor and operator=

Will Schroeder will.schroeder@kitware.com
Wed, 21 Nov 2001 10:09:36 -0500


Hi Folks-

I am going through all the code and making some pervasive changes.

1. Operator= and copy constructor are now private and not implemented

2. Documentation (in .h file) changes.

3. Copyright changes.

This email is about #1 above. We can talk about the other stuff next week.

In the past, itk::LightObject and all its subclasses have had the following 
lines:

protected: 
  vtkFoo(); 
  ~vtkFoo();
  vtkFoo(const vtkFoo&) {} 
  void operator=(const vtkFoo&) {}

Since the copy constructor and assignment operator (in subclasses of LightObject) are never called, 
there is no need for an implementation of these methods. In addition, it is better to make these methods private, since compile-time errors will appear if they are not declared (rather than link-time errors if they are not). So now operator= and the copy constructor are done thusly (using the standard Self typedef):

protected: 
  vtkFoo();
  ~vtkFoo();

private:
  vtkFoo(const Self&); //purposely not implemented
  void operator=(const Self&); //purposely not implemented

I am in the middle of checking this stuff in...Bill Lorensen found a problem on the SGI so I am making some tweaks. This should all be done in the next day or two.

If you write some new classes, please follow this procedure.

Will