Re: a case for multiple inheritance
- From: "Christof Nordiek" <cn@xxxxxxxxx>
- Date: Thu, 21 Jun 2007 09:05:05 +0200
"John" <no@xxxxxxxx> schrieb im Newsbeitrag
news:umle2e7sHHA.4548@xxxxxxxxxxxxxxxxxxxxxxx
Hi All,
Although C# has Generics, it still does not support the generic
programming paradigm. Multiple inheritance is required to support real
generic programming. Here is a simple design pattern to illustrate this.
Problem:
I need to expose two lists of objects from a high-level class. I would
like to expose these lists as read-only, but require write access
internally.
What ever your problem has to do with multiple inheritance it doesn't touch
Generics. The problem would remain the same if you used TList and
ProtectedTList instead of List<T> and ProtectedList<T>.
Solution:
1) Create a generic ProtectedList<T> class which inherits from List<T> and
overrides the write functions (using the new modifier) to change the
access level from public to protected.
You can't prevent access to inherited members. Even when hidden, it is still
accessible.
2) Inherit both specialized List<T> by the high-level class
I absolutly don't understand what this means. What are the two specialized
List<T>. I can only see List<T> and ProtectedList<T>. Since ProtectedList<T>
inherits from List<T> a class inheriting from ProtectedList<T> would also
inherit from List<T>, so it inherirts from both. Where MI comes into play.
Christof
.
- References:
- a case for multiple inheritance
- From: John
- a case for multiple inheritance
- Prev by Date: FTP Accessing Problem
- Next by Date: Re: Writing to Binary file
- Previous by thread: Re: a case for multiple inheritance
- Next by thread: Re: a case for multiple inheritance
- Index(es):
Relevant Pages
|
Loading