Lets discuss on the next code sample:
class A
{
public:
    int a;
};
class B:public A
{
public:
    int a;
};
int main()
{
    B b;
    std::cout << b.a;
    system("pause");
    return(0);
}
Why if I'm writing its like this, So its cant compiles, and giving me error.
But if I add a constructor to B class, like this:
B()
{
// An empty constructor!!!
}
then it prints on the screen a garbage value ('a' variable value.). And why I don't need any constructor if I'm writing the class like this:
 class B:public A
 {
 public:
     int a = 5;  // 5 is just one of many possibilities...
 };
In that case, 5 will be printed on the screen.
 
     
     
    