"Avner Flesch" <av***@il.marvell.com> wrote in message
news:3F**************@il.marvell.com...
Hi,
Do you know how can I intialize an array member:
for example
class A
{
public:
A(int x);
};
class B
{
public:
B();
private:
A a[2];
};
how do I intialize a?
Same way you initialize any other member(s), with a constructor.
B::B()
{
a[0] = A(1);
a[1] = A(2);
}
This isn't technically 'initialization', it's assignment, but
its the best that can be done with an (non static) array member.
The language does not provide an initializer list syntax
for arrays. Maybe consider a container (or perhaps a std::pair)
instead.
-Mike