Well whenever you create a custom class it has your default constructor which is called when the variable is simply declared.
However you can overload this constructor with additional variables.
For example let's say we have a class called wallet and we want it so when we create a value the default amount of money is 0. However we want their to also be an option so that we can declare it with a specified amount of money.
so mywallet = Wallet. //the total is 0
or mywallet = Wallet(100) //the total becomes 100
this is define in your constructor which normally follows what you define in your header or cpp file.
Wallet (); // Use default constructor (Note there is no return value)
Wallet (int total); // Use cosntructor with int.
This concept can further be applied to use a constructor with the same variable.
Wallet(Wallet); //this is the prototype for the copy constructor.
The point of a copy constructor is important as normally if you write.
Wallet myWallet = susansWallet it will be a shadow copy meaning myWallet now points to
SusansWallet if there is no copy constructor defined. So if you make any changed to Susans wallet it will be changed on myWallet and vice versa.
Now with the copy constructor you can specify what happens when you use wallet mywallet =susanswallet.
so for example:
Wallet(Wallet test){
total = test.total;
owner = test.owner;
}
so now myWallet and susansWallet will be equal to each other but not actually point to each other so changes made to myWallet will not affect susansWallet.