Table of ContentsControlling copies of objects The issue Objects versus values Values Objects Examples Variables are objects Pointers are values Arrays are (essentially) objects A concrete example One implementation snag Literals and aliasing Strings as values What is copying? What is a copy constructor? Overloading constructors First try Why X(X) doesn't work What do we really want Writing a copy constructor What operations should a String support? We can start coding Default constructor Construct a String from a character array The copy constructor The rest of it Example Two problems Assignment is not copying Defining assignment Example of assignment Assignment usually has three parts Referring to the present object Putting it all together Regrouping modules Implementation subroutines Revise the class Now we can initialize and destroy once The other operations become easier More operations Assignment Where are we now? The next couple of weeks |
Author: Andrew Koenig
Email: ark@research.att.com Home Page: http://www.research.att.com/info/ark |