copy constructor syntax

This commit is contained in:
Jidong Xiao
2025-01-17 11:59:58 -05:00
committed by JamesFlare1212
parent 1aace1130f
commit 237db36f55

View File

@@ -80,6 +80,12 @@ will sort Date objects into chronological order.
<!-- - Copy constructors are automatically generated by the compiler if you do not provide one explicitly. However, if your class uses dynamic memory (which will be covered in next lecture), and you want a copy constructor, then you must write your own copy constructor.-->
- Copy constructors get called when you create a new object by copying an existing object using the assignment operator (=), or when you pass an object by value to a function.
### Copy Constructor Syntax
```cpp
ClassName(const ClassName& other);
```
### Copy Constructor Example
```cpp