I want to use inheritance to make two classes and I want them to have same base class. Different derived classes and same base instance.
For example
1 2 3
class A { public: int x; };
class B : public A { int y };
B instance1, instance2;
When I change instance1.x=2 I want instance2.x to be 2 too. But not instance1.y and instance2.y, I want y variables to be discrete while x variables are same.
I just wondered is it possible to make what I wanted.
For example if I have a brother then we have the same mother, not with same type like height, weight, eye color etc. of two mothers but just one same mother. If my mother wears a red pullover, then my brother's mother wears the same red pullover too. Isn't that logical? I just thought that this type of inheritance could be made in C++