I
iluvatar
Hi all.
How can I initialize an array data member in the "faster" way? For
example, suppose I have a class like
class Example{
private:
double array[3];
public:
Example(const double & val0, const double & val1, const double &
val2); // yes, with doubles
...
};
and I want to write for the constructor something like
Example::Example(const double & val0, const double & val1, const double
& val2)
: array[0](val0), array[1](val1), array[2](val2)
{}
but obviously it does not work for me. I dont know what is the correct
syntax for the initialization, and if the member double array[3] MUST
be initialized with an array and no member by member as I did. Please
help me. Thank you. I am sorry for my English. Thank you again.
How can I initialize an array data member in the "faster" way? For
example, suppose I have a class like
class Example{
private:
double array[3];
public:
Example(const double & val0, const double & val1, const double &
val2); // yes, with doubles
...
};
and I want to write for the constructor something like
Example::Example(const double & val0, const double & val1, const double
& val2)
: array[0](val0), array[1](val1), array[2](val2)
{}
but obviously it does not work for me. I dont know what is the correct
syntax for the initialization, and if the member double array[3] MUST
be initialized with an array and no member by member as I did. Please
help me. Thank you. I am sorry for my English. Thank you again.