<P> When allocating memory dynamically, the constructor may be called by adding parenthesis after the class name . In a sense, this is an explicit call to the constructor: </P> <P> If the constructor does have one or more parameters, but they all have default values, then it is still a default constructor . Remember that each class can have at most one default constructor, either one without parameters, or one whose all parameters have default values, such as in this case: </P> <P> In C++, default constructors are significant because they are automatically invoked in certain circumstances; and therefore, in these circumstances, it is an error for a class to not have a default constructor: </P> <Ul> <Li> When an object value is declared with no argument list (e.g.: MyClass x;) or allocated dynamically with no argument list (e.g.: new MyClass; or new MyClass ();), the default constructor of MyClass is used to initialize the object . </Li> <Li> When an array of objects is declared, e.g. MyClass x (10);; or allocated dynamically, e.g. new MyClass (10). The default constructor of MyClass is used to initialize all the elements . </Li> <Li> When a derived class constructor does not explicitly call the base class constructor in its initializer list, the default constructor for the base class is called . </Li> <Li> When a class constructor does not explicitly call the constructor of one of its object - valued fields in its initializer list, the default constructor for the field's class is called . </Li> <Li> In the standard library, certain containers "fill in" values using the default constructor when the value is not given explicitly . E.g. vector <MyClass> (10); initializes the vector with ten elements, which are filled with a default - constructed MyClass object . </Li> </Ul>

When does java provide a default no-argument constructor