Copy Constructor
First seen in CS138 - Introduction to Data Abstraction and Implementation. Learned in CS247 - Software Engineering Principles.
Linked List ADT Copy constructor:
Compiler-Provided Copy Constructor
If we don’t provide an implementation of the copy constructor, the compiler provides a default Copy Constructor that simply copies all the fields.
Another example:
Why
*this
and not just*this
?Because
*this
is a pointer. And this makes sense on why you would dothis->data
instead ofthis.data
when you want to access specific member fields.
From CS138 - Introduction to Data Abstraction and Implementation: