Quick (easy) question on inheritance
So, about inheritance..
Suppose you have a few classes written precisely for a certain problem. They all require extern tags on several global variables, but now the variables are changing from global scope to local and need to be passed by reference. Would making a very generic class containing all of those global variables (passed in by reference) and then having those classes inherit that generic class be better than changing each and every class?
This question can be reduced to the following:
If you have a class with no functions or procedures (so, with only a few public variables) which is inherited by other classes, will the variables be seen as global by the inherited class?
Revision. In order to get the functionality I needed, I had to add two different files -- a "base case" class and a "wrapper" class; the first holds the variables as before with a set function (inherited by the few classes mentioned before) and the second which inherits the few classes through multiple inheritance. Then, I can just pass the variables into the wrapper by reference, which can then be passed to the base case, thus being passed to the few classes. Slow, dirty hack, yes, but it's better than rewriting everything.
Suppose you have a few classes written precisely for a certain problem. They all require extern tags on several global variables, but now the variables are changing from global scope to local and need to be passed by reference. Would making a very generic class containing all of those global variables (passed in by reference) and then having those classes inherit that generic class be better than changing each and every class?
This question can be reduced to the following:
If you have a class with no functions or procedures (so, with only a few public variables) which is inherited by other classes, will the variables be seen as global by the inherited class?
Revision. In order to get the functionality I needed, I had to add two different files -- a "base case" class and a "wrapper" class; the first holds the variables as before with a set function (inherited by the few classes mentioned before) and the second which inherits the few classes through multiple inheritance. Then, I can just pass the variables into the wrapper by reference, which can then be passed to the base case, thus being passed to the few classes. Slow, dirty hack, yes, but it's better than rewriting everything.
