Is it possible to get all specific types from a inheritance tree

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hello!

Assume I have a inheritande tree that looks like this.
I have Animal as the abstract superclass below this I have these abstract
classes
Mammal,Bird, Insect,Marine and Reptile.

The specific classes are for Mammal are Cat and Dog.
The specific classes are for Bird are Eagle and Pelican.
The specific classes are for Insect are Gnat and Fly.
The specific classes are for Marine are StoneFish and GoldFish
The specific classes are for Reptile are Snage and Frog .

So my question is if it's poosible to find the specific classes from this
inheritance tree.
So my goal is to get these classes(Types) Cat, Dog, Eagle, Pelican, Gnat,
Fly,StoneFish, GoldFish, Snake and Frog.

So if I would add a new Specific animal to the Bird class I should get that
class as well.

//Tony
 
Assume I have a inheritande tree that looks like this.
I have Animal as the abstract superclass below this I have these abstract
classes
Mammal,Bird, Insect,Marine and Reptile.

The specific classes are for Mammal are Cat and Dog.
The specific classes are for Bird are Eagle and Pelican.
The specific classes are for Insect are Gnat and Fly.
The specific classes are for Marine are StoneFish and GoldFish
The specific classes are for Reptile are Snage and Frog .

So my question is if it's poosible to find the specific classes from this
inheritance tree.
So my goal is to get these classes(Types) Cat, Dog, Eagle, Pelican, Gnat,
Fly,StoneFish, GoldFish, Snake and Frog.

So if I would add a new Specific animal to the Bird class I should get that
class as well.

You can get all types in an assembly.

You can get all super types of a given type.

You can not get all sub types of a given type.

So it depends a lot on what you have to start your
search with.

Arne
 
Arne Vajhøj said:
You can get all types in an assembly.

You can get all super types of a given type.

You can not get all sub types of a given type.

So it depends a lot on what you have to start your
search with.

Arne

If I start with the abstract Animal class can I then get all the specifc
types such as Cat ,Dog, Frog and so on.

//Tony
 
If I start with the abstract Animal class can I then get all the specifc
types such as Cat ,Dog, Frog and so on.

No.

As I said then you can get super but not sub types.

And you can find all types in a given assembly that
has Animal as super type.

You can also let all your classes register themselves
first time they get instantiated, so you have a list
of all sub types that has been instantiated at least
once in your program.

Arne
 
Back
Top