Copy Constructors - What, Why, and when to use one...
Post a Reply
|Oldest Newest Rating|
· April 13, 2015
Awesome thanks for explaining that!
· April 12, 2015
OK had to do some research too but lets see if I can explain it to you:
if you have an object and say it has a variable with a value of 3...
if you want to make another object, which has the same value of this variable you would need to get the value from this object and than you would need to pass it to the new created object
you can use a copy construcor
Lets give an example:
I have th object test from the class test_vars with a variable var = 3:
and if I want to copy this object WITHOUT a copy constructor i would need to do this.
and if i use copy constructor i only need to do this:
and I'm done.
See the difference it is way more clear than to get values and set values...
Here is a wikipedia article... sorry but its on german but the englisch version was really bad explained, hope you can figure it out.
Used in many types of software including music players, video games, and many large scale applications.
|Bucky Roberts Administrator|