CS 105: C++
Quiz 12 Requirements
C++: Chapter 9, 10

  1. Class instances can be assigned to each other using the assignment operator.  Know how to declare the assignment operator as a member function of a class.  What argument(s) does it take?  Be sure you know the precise syntax.

  2. Constructors can take arguments.  One such constructor is the copy constructor.  Know how to declare a copy constructor for a class.  What argument(s) does it take?  What does it return?  Be sure you know the precise syntax.

  3. If TextBox is a class, the following statements might be used to declare and initialize instances of that class.

    TextBox t1;
    Textbox t2 = t1;

    Does the initialization of t2 cause a call to TextBox's assignment operator, or its copy constructor?  Why?  (Note: The answer might not be what you expect, but it is covered in the recommended reading.)
  4. In Chapter 10 of the C++ book, the static-array version of class Id does not need to define a destructor, assignment operator, or copy constructor.  The dynamic-array version, however, needs to define all three of these.  Why is that?  (Note: The fact that if you need to define any one of these three for a class, you probably need to define all of them is often called "the Rule of Three".  Learn this concept and this name for it.)




Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.