473,546 Members | 2,244 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inheritage and classes

Hi,

Can I somehow specify that Class A can inherit from Class B *and* Class C?

--
Thanks,
Summa

Nov 16 '05 #1
5 1853
No - multiple inheritance is not possible in C# (nor any .Net language, I
believe).

You CAN, however, inherit from as many interfaces as you want, just only 1
class.

Adam Clauss
ca*****@tamu.ed u

"Summa" <su***@summarum .dk> wrote in message
news:c9******** ***@news.cyberc ity.dk...
Hi,

Can I somehow specify that Class A can inherit from Class B *and* Class C?

--
Thanks,
Summa


Nov 16 '05 #2
No, you cannot. C# does not support multiple inheritance of classes. But
you do multiple interface inheritance instead.

I hope this helps,

Jose Luis Manners, MCP

"Summa" <su***@summarum .dk> wrote in message
news:c9******** ***@news.cyberc ity.dk...
Hi,

Can I somehow specify that Class A can inherit from Class B *and* Class C?

--
Thanks,
Summa


Nov 16 '05 #3
C# doesn't support multiple inheritence.
Plus, it's often a sign of a bad design.

You *can* implement multiple interfaces though, and each interface can
derive from multiple interfaces.

"Summa" <su***@summarum .dk> wrote in message
news:c9******** ***@news.cyberc ity.dk...
Hi,

Can I somehow specify that Class A can inherit from Class B *and* Class C?

--
Thanks,
Summa


Nov 16 '05 #4
Hi,

Just a "thanks" to all of you :)

I havent noticed interfaces before, but from what I can read, its just a
template class kinda. I still have to implement all functionality in the
Class that inherits them. So what Im really inheriting is just "contracts"
of how the structure must look like. Correct?

--
regards,
Summa

Nov 16 '05 #5
By simulating multiple inheritance via interfaces, you just get the
kind of mess VB6 programmers used to create by using interfaces to
simulate single inheritance.

Use interfaces for what they are intended for. There is no multiple
inheritance in .net, and for good reason - it sucks and probably
means you have a bad design. If you try to fake it with interfaces,
you then have a mess on top of a bad design.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
741
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is visible in those assemblies from a managed point-of-view I've noticed that: 1) for each managed and unmanaged C function (not C++ classes) I get a public managed static method...
9
1630
by: Jack | last post by:
Hello I have a library of calculationally intensive classes that is used both by a GUI based authoring application and by a simpler non-interactive rendering application. Both of these applications need to serialise the classes to/from the same files but only the GUI app needs the full range of class methods. Now, the rendering app needs...
9
6629
by: Aguilar, James | last post by:
I know that one can define an essentially unlimited number of classes in a file. And one can declare just as many in a header file. However, the question I have is, should I? Suppose that, to use the common example, I have a situation where I am implementing many types of Shapes. My current way of thinking is, well, since they are all...
12
21205
by: Langy | last post by:
Hello I'm fairly new to C++ but have programmed several other languages and found most of c++ fairly easy (so far!). I've come to a tutorial on classes, could someone please tell me why you would need to use a class? Perhaps you could also give an example on when it might be used rather than an alternative method.
3
1100
by: mandatory | last post by:
hi, i have two classes: class A { public: virtual Push (void *p); };
2
9483
by: joye | last post by:
Hello, My question is how to use C# to call the existing libraries containing unmanaged C++ classes directly, but not use C# or managed C++ wrappers unmanaged C++ classes? Does anyone know how to do that? Thanks. Tsung-Yu
18
2027
by: Edward Diener | last post by:
Is the packing alignment of __nogc classes stored as part of the assembly ? I think it must as the compiler, when referencing the assembly, could not know how the original data is packed otherwise. Yet, in my understanding, attributes are only __gc and __value class specific and do not apply to __nogc classes. Is this correct ? If so, how is...
6
2923
by: ivan.leben | last post by:
I want to write a Mesh class using half-edges. This class uses three other classes: Vertex, HalfEdge and Face. These classes should be linked properly in the process of building up the mesh by calling Mesh class functions. Let's say they point to each other like this: class Vertex { HalfEdge *edge; }; class HalfEdge { Vertex* vert;
0
2020
by: ivan.leben | last post by:
I am writing this in a new thread to alert that I found a solution to the problem mentioned here: http://groups.google.com/group/comp.lang.c++/browse_thread/thread/7970afaa089fd5b8 and to avoid this topic getting lost before people interested in the problem notice it. The important tricks to the solution are two: 1) make the custom classes...
0
7507
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7947
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7461
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7794
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5361
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5080
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3492
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3472
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.