In C++, we have Copy Constructor, Destructors, overloaded = which are together called copy control.
My questions are:
-
Is
copy constructorused inC#for initializing objects when passed to a function asargumentor wheninitializing(not assigning) or whenreturningan object from afunctionas inC++? -
Does an implicitly overloaded
=operator function gets called when we assign (not initialize) any object to another object of the same type?
In fairness to C#, none of the intricacies of the C++ copy control are necessary because of the underlying garbage-collected memory model. For example, you do not need to control the ownership of dynamically allocated objects when copying objects, because you are free to have as many references to dynamic objects as you wish.