S
subramanian100in
If we do not provide any ctor for a class, the compiler provides the
default ctor and copy ctor if needed.
Consider a class Test.
Suppose we provide some ctor in class Test but do not provide the
default ctor.
Suppose we try to create
Test obj;
Here the default ctor is needed and the compiler does not provide the
default ctor but generates a compilation error.
However if we provide some ctor but do not provide the copy ctor, the
compiler does not generate error but provides the copy ctor if needed.
Why doesn't the compiler give error for the absence of copy ctor
similar to error for the absence of default ctor.
Kindly explain
Thanks
V.Subramanian
default ctor and copy ctor if needed.
Consider a class Test.
Suppose we provide some ctor in class Test but do not provide the
default ctor.
Suppose we try to create
Test obj;
Here the default ctor is needed and the compiler does not provide the
default ctor but generates a compilation error.
However if we provide some ctor but do not provide the copy ctor, the
compiler does not generate error but provides the copy ctor if needed.
Why doesn't the compiler give error for the absence of copy ctor
similar to error for the absence of default ctor.
Kindly explain
Thanks
V.Subramanian