On 2007-08-15 08:55,
subramanian100in@yahoo.com, India wrote:
Quote:
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.
Because the generation of default ctor and copy ctor are independent of
each other. If you declare any ctor (even a copy ctor) the compiler wont
generate a default ctor. If you declare a copy ctor the compiler wont
generate a default copy ctor, nor will it generate a default ctor.
--
Erik Wikström