The Class Object array is defined in the same way as the built-in type array, for example
Account table [16];
Defines an array containing 16 account objects, and each element uses the default account to construct the initial function.
If you like, you can use the initialization table in parentheses to provide explicit real parameters for the constructor, for example
Account pooh_pals [] = {"Piglet", "Eeyore", "Tigger "};
An array that defines three elements.
Account ("Piglet", 0.0); // The first element
Account ("Eeyore", 0.0); // second element
Account ("Tigger", 0.0); // The third element
Initialization
A single real parameter of the constructor can be explicitly specified as shown in the preceding example.
Real parameters, you need to use the complete constructor syntax, such
Account pooh_pals [] = {
Account ("Piglet", 1000.0 ),
Account ("Eeyore", 1000.0 ),
Account ("Tigger", 1000.0)
};
If you want to specify the default constructor in the array initialization table, we can use the complete structure with an empty parameter table.
Function syntax example
Account pooh_pols [] = {
Account ("Woozle", 10.0 ),
Account ("heffalump", 10.0 ),
Account ()
};
We can also obtain the equivalent array of the three elements as follows:
Account pooh_pols [3] = {
Account ("Woozle", 10.0 ),
Account ("heffalump", 10.0)
};
====================
// Indicates that pact points to an array
Delete [] Pact;
Empty Square brackets indicate that pact points to an array compiler and obtains the number of elements in the array. This ensures that the Destructor is applied to each element.