Simple multiple choice question; Assignment Operator

1. What type of copy is performed when using the assignment operator with two
objects if the assignment operator has not been overloaded?
a. Carbon copy
b. Shallow copy
c. Deep copy
d. Serious copy
e. Xerox copy

I'm thinking it's b.. Can anyone confirm and explain? Thank you

And another one, I think this one is A?
2. When executing the constructor of a derived class, when is the constructor of the
base class invoked?
a. At the beginning of the constructor function
b. At the end of the constructor function
c. At the end of the constructor’s prototype
d. When it is explicitly called in the function
e. When to object goes out of scope

And last one,
3. Why is the second parameter of the following function passed as a constant
reference rather than passed by value?
ostream& operator<<(ostream& out, const addressType &address)

a. Because the function will change its value
b. Because operator overload functions cannot take a by-value argument
c. So that the entire class will not be passed on the stack, thus saving
memory space and execution time, but at the same time disallowing the
function to change the value of address
d. Because objects cannot be passed by-value
e. Because all operands to a binary function must be constant references.

This one I think is A? But it's << so it wouldn't be changing?

Any help would be appreciated, thank you
Last edited on
no, you can specify how to copy. If you assign the copy you just specify..... if this is a test question.... assume your professor is an idiot. and just give him an answer he can't understand.
They are practice questions for my final tomorrow. what about 2 and 3?
I hear ya man, one i think A..
2... i think... d.
3. well it labels it as constant so i would say e.
let me know man. these are just trick questions.
1. What type of copy is performed when using the assignment operator with two
objects if the assignment operator has not been overloaded?
a. Carbon copy
b. Shallow copy
c. Deep copy
d. Serious copy
e. Xerox copy

I'm thinking it's b.. Can anyone confirm and explain? Thank you

Your teacher almost certainly expects the answer to be b.

The type of copy performed is the copy provided by the implicitly-declared copy assignment operator.
http://en.cppreference.com/w/cpp/language/as_operator
You may want to think of this as 'member-wise copy assignment'


And another one, I think this one is A?
2. When executing the constructor of a derived class, when is the constructor of the
base class invoked?
a. At the beginning of the constructor function
b. At the end of the constructor function
c. At the end of the constructor’s prototype
d. When it is explicitly called in the function
e. When to object goes out of scope

Yes. See Initialization order in: http://en.cppreference.com/w/cpp/language/initializer_list


3. Why is the second parameter of the following function passed as a constant
reference rather than passed by value?
ostream& operator<<(ostream& out, const addressType &address)

a. Because the function will change its value
b. Because operator overload functions cannot take a by-value argument
c. So that the entire class will not be passed on the stack, thus saving
memory space and execution time, but at the same time disallowing the
function to change the value of address
d. Because objects cannot be passed by-value
e. Because all operands to a binary function must be constant references.

This one I think is A? But it's << so it wouldn't be changing?


The expected answer is c.
Though another valid reason could be that addressType is not a CopyConstructible type.
Thank you so much.
Topic archived. No new replies allowed.