When I declare a an array, all the variables/objects get declared. But what happens with the objects, if their class has constructors? The class I’m using has 2 constructors – one with no arguments and one with a few arguments. Will the first constructor activate after the declaration? Or no constructors will activate?
If the first case happens, I’ll have to make a function that replaces the constructors.
So, what happens with the objects in a newly declared array?
It depends how you declare the array. The members will be either default, value, or copy-initialized:
For class types, default- and value-initialization call the default constructor. Copy-initialization may call the appropriate constructor directly.
If you don’t want to use the default-constructor, you won’t get arround the brace-initializer and spelling out each member.