Member Initializer List

why member initializer list feature is introduced because we can also provide initialization in function's body ?
No we can't: every direct base and every member is initialized before the body of the constructor is entered. If you don't mention them in the list, they are default-initialized.
All you can do in the body is to replace the contents of the members, e.g. by assigning to them (where possible)
All data members in the body of a constructor are not initialized. They are assigned. So you can not initialize for example a constant data member, or call a constructor of an subobject with parameters, or can not call a constructor of a virtual base class.
class A {
const int a;
int cap;

A(int ab , int capacity) {
a=ab; // Error

Am i right ???
It is me who is right. As for you then you are unable even to try to compile your example and to see what is the result.
Ok...vlad you are right ... happy ??

Thnx for the help
Ok vlad you r right .... Happy?

Thnx for help
Topic archived. No new replies allowed.