I dont think it is a OOP issue.
In my case I have a Sprite type with a global list of all sprites created. The New() method adds itself to the list. This means any new types I create that derive from the Sprite will also automatically add themselves to the List. That is what it is supposed to do. All the derived types are still basically a sprite and therefore do everything a sprite type does.
What your asking for is that each derived type share all the common code but use a unique global field.
I dont think any OO language will do what you want.
In C++ I think you could achieve what you want using Templates. My C++ is not very hot but from what I understand you would write your common code as a template. Then each of the classes you want can be created from the template. The compiler would insert the common code for you. In effect each of the classes would be copies of the template. Equivalent to you cut/pasting your base code into each of your required types.
The alternative is to redesign your code to work differently.
for example : How about if you make the TList local in your base type.
The top level database type will use the TList to store a list of tables.
Each table type stores a List of Columns. So whenever you create a Table the table will have it's own list in which to store the columns.
Just a thought.
In my case I have a Sprite type with a global list of all sprites created. The New() method adds itself to the list. This means any new types I create that derive from the Sprite will also automatically add themselves to the List. That is what it is supposed to do. All the derived types are still basically a sprite and therefore do everything a sprite type does.
What your asking for is that each derived type share all the common code but use a unique global field.
I dont think any OO language will do what you want.
In C++ I think you could achieve what you want using Templates. My C++ is not very hot but from what I understand you would write your common code as a template. Then each of the classes you want can be created from the template. The compiler would insert the common code for you. In effect each of the classes would be copies of the template. Equivalent to you cut/pasting your base code into each of your required types.
The alternative is to redesign your code to work differently.
for example : How about if you make the TList local in your base type.
The top level database type will use the TList to store a list of tables.
Each table type stores a List of Columns. So whenever you create a Table the table will have it's own list in which to store the columns.
Just a thought.