I want wndproc to inherit from A because I want it to be able to see, use, and modify the member variables of A. |
OK, that is absolutely not a reason to use inheritance. Inheritance is not there as a convenient shortcut around the principles of encapsulation.
Put simply, inheritance models an "is-a" relationship - that is, it would be relevant if
wndproc is a type of
A. The parent class defines data and behaviour that is common to all objects of that type, and, crucially, the interface that all objects of that type will have. Specialised behaviour and data goes into the subclasses.
For example, if you were writing a program that dealt with vehicles, you might have a
Vehicle base class that includes things common to all vehicles, including a common interface. If you then needed cars to behave differently from aeroplanes, you might then have Car and Plane classes, each of which would define the behaviour specific to those types, while conforming to the Vehicle interface, and inheriting common behaviour from Vehicle.
There's a lot more that could be said about inheritance. I suspect this would be a good point to find a tutorial on object-oriented design, so that you know what classes are actually
for, and how to use features like inheritance.