[vtkusers] copying a vtkUnstructuredGrid ?

Charl P. Botha c.p.botha at its.tudelft.nl
Tue Jul 9 05:55:01 EDT 2002


On Tue, Jul 09, 2002 at 10:16:20AM +0100, Tim Hutton wrote:
> Just to explain, none of the classes have either their copy constructor or 
> the assignment operator implemented, this is by design. They are marked 
> with the comment "not implemented" and declared as private to stop the 
> compiler creating default versions.
> 
> I understand the reason is to allow complete binding of VTK to scripting 
> languages such as tcl that don't deal with objects - whatever language you 
> are using you have to use New() and Delete() and DeepCopy(). It's a bit 
> weird for C++ people but enables easy translation to/from the other 
> languages, which is fantastic.

Tim, try not to top-quote.  I was not able to put my suggestions in the
context of your and the previous authors' postings because of the
top-quoting. http://www.xs4all.nl/~hanb/documents/quotingguide.html has more
information on this.

You're right about the unimplemented copy and assignment being there to
prevent the compiler "creating default versions".  This is simply good
practice and prevents the classes being used in ways that they were not
designed for.  For example, if you were to try to pass a VTK instance by
value, this would result in the copy constructor being invoked.  Because
there's an unimplemented copy constructor, this will trigger a compiler
error, which is a good thing, as VTK instances aren't usually supposed to be
passed by value.  If we didn't have the unimplemented copy ctor, the
compiler wouldn't complain and we would have to deal with a most
difficult-to-find bug.

Best regards,
Charl

-- 
charl p. botha http://cpbotha.net/ http://visualisation.tudelft.nl/



More information about the vtkusers mailing list