0

How to understand copy constructor better?

I get how copy constructor works but i don't know why it works. I am just curious why it is necessary to initialize the constructor variables to the local variables? Like: public Fraction (Fraction other){ this.num = other.num; this.denom = other.denom; } Why do I have to do this?

28th Sep 2019, 9:46 PM
arl
1 Resposta
0
You can do this if you want to create a real copy. I hope my code helps you a little bit: https://code.sololearn.com/c5xaS2p56ORh/?ref=app
28th Sep 2019, 11:54 PM
Denise Roßberg
Denise Roßberg - avatar