C
Chuck Cobb
I have a question regarding generics: Suppose I want to create some generic
collection classes:
Collection<Cats> c;
Collection<Dogs> d;
and both Cats and Dogs are inherited from a base class called Animals. I'd
like to have a class:
Collection<Animals>
that has all the common routines for collections of Cats and Dogs defined.
How do I do that?
The problem I'm having trouble understanding is this...both Collection<Cats>
and Collection<Dogs> are inherited from Collection<T> where T is just a type
identifier (not a real type). What I would like to be able to do is have
Collection<Cats> and Collection<Dogs> inherited from Collection<Animals> and
that is inherited from Collection<T> so that I can define some common
routines in Collection<Animals>. Is there a way to do that?
Thanks,
Chuck Cobb
collection classes:
Collection<Cats> c;
Collection<Dogs> d;
and both Cats and Dogs are inherited from a base class called Animals. I'd
like to have a class:
Collection<Animals>
that has all the common routines for collections of Cats and Dogs defined.
How do I do that?
The problem I'm having trouble understanding is this...both Collection<Cats>
and Collection<Dogs> are inherited from Collection<T> where T is just a type
identifier (not a real type). What I would like to be able to do is have
Collection<Cats> and Collection<Dogs> inherited from Collection<Animals> and
that is inherited from Collection<T> so that I can define some common
routines in Collection<Animals>. Is there a way to do that?
Thanks,
Chuck Cobb