In your example Admin, Instructor and Stuent could all override methods of
the User base class - which of these overrides should be chosen for the
HybridUser class? (Note that this does not apply to interfaces, as they
don't contain an implementation)
That's the one of the major problems of multiple inheritance, and one of the
causes why it isn't possible in C#.
Personal suggestion: Build a class hierarchy for User-Groups:
UserGroup
Admin : UserGroup
Instructor : UserGroup
Student : UserGroup
And let each User object contain a list of UserGroups it belongs to.
That way you can enumerate what groups a user belongs to (not possible in
C++ without reflection), and decide for each method what should be done if
more than on UserGroup is in the list.
Niki
"Timothy V" <tr****@msn.com> wrote in
news:uV****************@TK2MSFTNGP12.phx.gbl...
Hi,
I'm new to C# but i know a little of C++. My problem is inheritance within
c#, im not sure how to do it. For example, i know that a class can only
inherit one base class. But what if i want to do this:
User
Admin : User
Instructor : User
Student : User
HybridUser : Admin, Instructor, Student
How do i declare/create the Hybrid user within C#?
Thank you in advance,
Timothy.