B derives public-ly from A. That roughly saying "B is of type A" AND "B has its own set of properties that may differ from A". Why don't you run the code yourself and check if b.x is 10? Is it 10 though? Try it Just add this to your code tho (so that you don't have uninitialised value usage):

Code:
class A {public: int x = 0;};
class B : public A {int y = 0;};