Look at the first class :
class A
{
public:
int x;
A(int v) { x=v; }
};
Also, take a look at class B ( i used inheritance )
class B : public A //Inheritance{
public:
B(int v) :A(v) {y=v; }
int y;
};
Now can you explain why we use :A (v)
?, i know that the initializer list can be used to initialize member variables, but... constructors ?! .
i think there's something about the initializer that i don't know, can you give me a good place to read about it ?