F
Fred Zwarts
If I am right, members of a class that are const and not static
must be initialized in the initialization part of a constructor.
E.g.
class C {
private:
const int I;
public:
C();
};
This class requires that the constructor initializes I in the
initialization part. E.g.:
C::C () : I(5) {}
How is this done for a const array, e.g., if C is modified as:
class C {
private:
const int I[3];
public:
C();
};
How is the array I initialized?
I cannot find the syntax for initializing the array.
Of course, the question does not only apply to int types,
but also to more complex (class) types.
F.Z.
must be initialized in the initialization part of a constructor.
E.g.
class C {
private:
const int I;
public:
C();
};
This class requires that the constructor initializes I in the
initialization part. E.g.:
C::C () : I(5) {}
How is this done for a const array, e.g., if C is modified as:
class C {
private:
const int I[3];
public:
C();
};
How is the array I initialized?
I cannot find the syntax for initializing the array.
Of course, the question does not only apply to int types,
but also to more complex (class) types.
F.Z.