Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 26th, 2006, 11:22 AM
Authorized User
 
Join Date: Oct 2004
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default Why C# is not supporting Multiple Inheritance?

Hi,

Why C# alone is not supporting Multiple Inheritance, when we are able to achieve same thing in C++/Java.

Can anybody explain with a good example?

Ramkumar

A.D.Ramkumar
__________________
Ramkumar A D
 
Old February 26th, 2006, 07:16 PM
Wrox Technical Editor
 
Join Date: Dec 2005
Posts: 271
Thanks: 0
Thanked 0 Times in 0 Posts
Default

C# doesn't allow multiple implement inheritance directly; however it does allow multiple interface inheritance. An interface and abstract class are almost exactly the same thing.

Multiple Inheritance (MI) has not been implemented for the following reasons:

1. .NET allows the use of different languages, each of these languages would have different expectations on how MI works. Microsoft has not gotten around to resolving these differences.

2. The number of places where MI is appropriate is very small. Most often Multiple Interface Inheritance can get the job done.

3. MI injects a lot of complexity into the implementation.

For a more complete overview see: http://blogs.msdn.com/csharpfaq/arch.../07/85562.aspx

- A.Kahtava
 
Old February 26th, 2006, 07:23 PM
Wrox Technical Editor
 
Join Date: Dec 2005
Posts: 271
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Simulated Multiple Inheritance Pattern for C#: http://www.codeproject.com/csharp/smip.asp

- A.Kahtava
 
Old February 27th, 2006, 02:08 AM
Wrox Technical Editor
 
Join Date: Dec 2005
Posts: 271
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Java like C# was designed without multiple implementation inheritance; however both languages provide multiple interface inheritance.

Out of your list of languages, C++ is the only language that supports both types of multiple inheritance.

"The one indisputable fact about multiple inheritance in C++ is that it opens up a Pandora’s box of complexities that simply do not exist under single inheritance." - Scott Meyers

Single interface inheritance can accomplish much the same as both interface and implementation inheritance.
Came across that quote today, thought it was suiting.

- Adam Kahtava [http://adam.kahtava.com]
 
Old April 26th, 2006, 07:11 AM
Authorized User
 
Join Date: Oct 2004
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

If some body can explain me with practical scenario, it will be far better.

Expecting for your reply.

Ramkumar A.D.

A.D.Ramkumar
 
Old April 26th, 2006, 08:05 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Can I rephrase your question?
Can you give a practical example of when you would want to use multiple inheritance?

--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Interface Vs Multiple inheritance anand_instra C# 1 April 30th, 2008 12:16 PM
Multiple inheritance with VTable subhash_w Visual C++ 2005 1 July 31st, 2005 02:41 PM
Multiple inheritance with VTable subhash_w C++ Programming 0 July 31st, 2005 04:40 AM
Multiple inheritance with VTable subhash_w BOOK: Professional C++ 0 July 31st, 2005 04:35 AM
multiple inheritance in C# mehdi62b C# 3 December 2nd, 2004 06:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.