Answer the question
In order to leave comments, you need to log in
Why can't the constructor Class ( Class other) { } take an object of its type by value?
Assumptions: A constructor is essentially a function that returns nothing, gets the address of its object implicitly, and gets something else in the parameter list explicitly. Parameters are allocated on the calling function's stack and used by the called function.
Why doesn't this logic work with constructor? Just because or there are some complicated reasons? It is clear that this is inefficient and pointless.
Answer the question
In order to leave comments, you need to log in
Because in order to pass any argument by value, it must be copied. To copy an argument that is an object of a class, you need to call the copy constructor (whether automatically generated or manually written).
Thus, to "go inside" the copy constructor, to which the argument is passed by value, you need to call ... the copy constructor. of the same class. Those. the same constructor.
Like it should be clear.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question