+ 1
Copy constructors
Help copy constructors
10 ответов
+ 3
As you may know, the copy constructor is used to create a new object from another existing object.
here is an example on how a copy constructor would look like:
https://code.sololearn.com/c0STVh9BU3p2/#cpp
+ 3
as @Tyrant says the C++ compiler creates a default copy constructor for each class which does a member-wise copy between objects but you need to define your own copy constructor only if the object has pointers or any runtime allocation of the resource.
+ 2
Copy constructors are created automatically when you create classes.You dont need to worry about them,well most of the time anyway,...
+ 2
Well,in that case i think its ok to create a copy constructure..Do you need help creating copy constructures...Im happy to help...
+ 1
thanks for the example!
+ 1
yeah, the copy constructor takes one parameter( reference to the type for which it belongs )
+ 1
ok, i like your example better than the text book from my class
0
what it you need to define a user defined copy constructor without overwroting previously written data?
0
honestly yes... simple examples alwyas help
0
so the copy constructor takes an app object as its in parameter?