"Tony Johansson" <jo*****************@telia.com> wrote in message
news:rk*********************@newsc.telia.net...
Hello!!
Hello Experts!
I'm right if I say that if I have attribute that is constant or attribute
that is of reference type or attribute that is class type then I must use
initialize list.
//Tony
If the member variable (what you've called "attribute") is a class object,
then you _can_ initialze it via the member initializer list, but you don't
_have_ to. If it exists, or can be generated by the compiler then, the
default constructor for the contained class object will be called during
construction of the containing class. But if there is no default
constructor, or if the compiler is unable to generate one (because you've
declared one or more constructors yourself), then yes, you will need to
construct it via the member initializer list. (And you may want to, anyway,
since it's the only way to pass parameters to that object's constructor.)
-Howard