If I have a struct that consists of two objects of a class, and I create an array of those structs without initially setting the values of the objects to anything, what will be contained in that array? Does it create structs using the default constructor for that struct?
My specific example requires me to use the last element of the array recursively to determine what the next element of the array is, and I need all the elements initially set to what the default constructor provides.
The array I am creating and the way I am declaring it is:
s arrayname [5];
My struct is essentially along the lines of:
struct s{
Vectorh a, b;
s();
}
where Vectorh is a class that contains four double values, plus a lot of functions. I also have a default constructor in this struct, which is defined as:
s(){
a = Vectorh(); // Vectorh() creates a Vectorh with all components set
b = Vectorh(); // to (double)0
}
Finally, Vectorh is defined as:
class Vectorh{
double x, y, z, w;
}
with the constructors
Vectorh(double a, double b, double c){
x = a;
y = b;
z = c;
w = (double)0;
}
Vectorh(){
x = (double)0;
y = (double)0;
z = (double)0;
w = (double)0;
}
Edit: The linked question says nothing about empty initialization at all. It only talks about initialization with elements.
... ={};to value initialise the array. Default is uninitialised.