I wonder if anyone could explain what the default ctor does after memory allocated, how it initializes the allocated memory?
Default constructors invoke the default constructors of all non-static data members, except those of built-in types, which remain uninitialised.
[2003: 12.1/5]
:
A default constructor for a class X is a constructor of class X that can be called without an argument. If there is no user-declared constructor for class X, a default constructor is implicitly declared.
[2003: 12.1/8]
:
Default constructors are called implicitly to create class objects of static or automatic storage duration (3.7.1, 3.7.2) defined without an initializer (8.5).
I don't know which languange you asked the question for, but I will try to answer anyway for C++ and Java
In C++, it :
int
, float
, pointers, etc.) to an uninitialized valueIn Java, I think all class members are initialized to their default value (0 or NULL).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With