, India wrote:
> If we provide a any non-default ctor, then the compiler doesn't
> supply the default ctor even if needed. This behaviour is due the
> following reason as per my understanding:
> It is for DISALLOWING an object to be created without arguments.
This needs to be expressed more carefully: It is for disallowing object creation
using a constructor that has been generated by the compiler. Altough this
statement may seem not to be different from the original statement of yours, it
encloses the case where a explicitly declared constructor has default values for
its arguments:
class Test
{
Test (int i = 2);
};
Here we can construct an object without passing arguments but it is still not
the default constructor.
> For example, for a class named Test, creating
> Test obj;
> may not have to be allowed for the particular class Test. Under this
> circumstance, we expect a provision from the compiler, not to
> supply the default ctor.
> Is my understanding correct ?
I very much think so.
Regards,
Stuart