473,804 Members | 2,202 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is this possible in VB.NET !??! inheritance..

Imagine I have two classes A and B.

Class A has the function I, function J and Attribute K.

Class B has the funcion X, function Y, Attribute Z.

Is it possible to establish the following Class C through interitance:

Class C which has the attribute K inherited from Class A and the attribute Z
inherited from Class B ?

If this is not possible why not!??! In the real world example I was thinking
of maybe
An CustomerInvoice class , that interhited the attributes from a Customer
class, Product class and Order class, but necessarily all of the functions.
Nov 21 '05 #1
9 1746
Sure. Have Class B inheirit from Class A then create a new class C that
inheirits B.

"bob taylor" wrote:
Imagine I have two classes A and B.

Class A has the function I, function J and Attribute K.

Class B has the funcion X, function Y, Attribute Z.

Is it possible to establish the following Class C through interitance:

Class C which has the attribute K inherited from Class A and the attribute Z
inherited from Class B ?

If this is not possible why not!??! In the real world example I was thinking
of maybe
An CustomerInvoice class , that interhited the attributes from a Customer
class, Product class and Order class, but necessarily all of the functions.

Nov 21 '05 #2
You cant do multiple inheritance in VB.NET. You can do what Dennis suggests,
or create interfaces for the multiple objects and implement all the
interfaces.

Rgds,
Anand M
VB.NET MVP
http://www.dotnetindia.com

"bob taylor" wrote:
Imagine I have two classes A and B.

Class A has the function I, function J and Attribute K.

Class B has the funcion X, function Y, Attribute Z.

Is it possible to establish the following Class C through interitance:

Class C which has the attribute K inherited from Class A and the attribute Z
inherited from Class B ?

If this is not possible why not!??! In the real world example I was thinking
of maybe
An CustomerInvoice class , that interhited the attributes from a Customer
class, Product class and Order class, but necessarily all of the functions.

Nov 21 '05 #3
Bob,

There was a discussion some weeks ago about this, however you said a real
world example

In real live you can have a class humans
You can even inherit the class man from that
And you can inherit the class woman from that

But it is not logical to make a class humans again from man and womans.

A specific man can have special appierance (what he got maybe from his
mother, who got it maybe from her father), however that are in my opinion
not class properties as by instance 7 neck bones as is for most mammals.

Trying to do it in another way gives in my opinion bad design.

Just my thought,

Cor

"bob taylor" <bob ta****@discussi ons.microsoft.c om>
Imagine I have two classes A and B.

Class A has the function I, function J and Attribute K.

Class B has the funcion X, function Y, Attribute Z.

Is it possible to establish the following Class C through interitance:

Class C which has the attribute K inherited from Class A and the attribute
Z
inherited from Class B ?

If this is not possible why not!??! In the real world example I was
thinking
of maybe
An CustomerInvoice class , that interhited the attributes from a Customer
class, Product class and Order class, but necessarily all of the
functions.

Nov 21 '05 #4
What do you mean interfaces !!? omg I am lost.

Is there a reason why multiple inheritance is not supported !?!?!?
Do other OOP languages like Java support it !?

"Anand[MVP]" wrote:
You cant do multiple inheritance in VB.NET. You can do what Dennis suggests,
or create interfaces for the multiple objects and implement all the
interfaces.

Rgds,
Anand M
VB.NET MVP
http://www.dotnetindia.com

"bob taylor" wrote:
Imagine I have two classes A and B.

Class A has the function I, function J and Attribute K.

Class B has the funcion X, function Y, Attribute Z.

Is it possible to establish the following Class C through interitance:

Class C which has the attribute K inherited from Class A and the attribute Z
inherited from Class B ?

If this is not possible why not!??! In the real world example I was thinking
of maybe
An CustomerInvoice class , that interhited the attributes from a Customer
class, Product class and Order class, but necessarily all of the functions.

Nov 21 '05 #5
Bob,
By "Multiple inheritance" do you mean "IS A" or "HAS A".

For example a Car has a Tire, however a Car is not a Tire.

Multiple inheritance normally refers to "IS A", however you Customer Invoice
example sounds like "HAS A". As the others have suggested .NET (VB.NET & C#)
along with Java do not support multiple inheritance except via Interface.

I would expect a CustomerInvoice would have a Customer, a Product, and an
Order.

However CustomerInvoice would not be a Customer, a Product, nor an Order.

Class C which has the attribute K inherited from Class A and the attribute
Z
inherited from Class B ? Based on the CustomerInvoice example, I would expect:

Class C
Public Property A As A
Public Property B As B
End Class

Or with CustomerInvoice :

Class CustomerInvoice
Public Property Customer As Customer
Public Property Order As Order
Public Property Product As Product
End Class

Then within my code I could:

Dim invoice As CustomerInvoice
invoice.Custome r.Name = "Jay"
invoice.Custome r.Address = "Everywhere "

invoice.Order.A mount = $1

Hope this helps
Jay


"bob taylor" <bob ta****@discussi ons.microsoft.c om> wrote in message
news:13******** *************** ***********@mic rosoft.com... Imagine I have two classes A and B.

Class A has the function I, function J and Attribute K.

Class B has the funcion X, function Y, Attribute Z.

Is it possible to establish the following Class C through interitance:

Class C which has the attribute K inherited from Class A and the attribute
Z
inherited from Class B ?

If this is not possible why not!??! In the real world example I was
thinking
of maybe
An CustomerInvoice class , that interhited the attributes from a Customer
class, Product class and Order class, but necessarily all of the
functions.

Nov 21 '05 #6
Use the relatively cleaner and newer language from the devil. Use C #.
It has all that Vb.net offers as a language and multiple inheritance
also. Be warned that the design time envirionment [I was informed , i
have not even tried] for c# may make you cry for ..mummy!..
"Anand[MVP]" <An******@discu ssions.microsof t.com> wrote in message news:<1A******* *************** ************@mi crosoft.com>...
You cant do multiple inheritance in VB.NET. You can do what Dennis suggests,
or create interfaces for the multiple objects and implement all the
interfaces.

Rgds,
Anand M
VB.NET MVP
http://www.dotnetindia.com

"bob taylor" wrote:
Imagine I have two classes A and B.

Class A has the function I, function J and Attribute K.

Class B has the funcion X, function Y, Attribute Z.

Is it possible to establish the following Class C through interitance:

Class C which has the attribute K inherited from Class A and the attribute Z
inherited from Class B ?

If this is not possible why not!??! In the real world example I was thinking
of maybe
An CustomerInvoice class , that interhited the attributes from a Customer
class, Product class and Order class, but necessarily all of the functions.

Nov 21 '05 #7
Mahesh Naik wrote:
Use the relatively cleaner and newer language from the devil. Use C #.
It has all that Vb.net offers as a language and multiple inheritance
also. Be warned that the design time envirionment [I was informed , i
have not even tried] for c# may make you cry for ..mummy!..


I'm certain that I'm correct in saying that the .Net framework itself
doesn't offer multiple inheritance, which means that C# (just like VB.Net)
doesn't support multiple inheritance. The only thing you can do is implement
multiple interfaces or use multiple levels of single-inheritance objects, as
already described.

--

(O)enone
Nov 21 '05 #8
Question.. I'm really new at this so bear with me..

Couldn't you do this:

Public Class NewClass
Inherits A

Public Class FromB
Inherits B
End Class
End Class

And just have the properties for the attributes of B in the newclass and
in the functions for those properties just get and set in the FromB class???

Aaron

Oenone wrote:
Mahesh Naik wrote:
Use the relatively cleaner and newer language from the devil. Use C #.
It has all that Vb.net offers as a language and multiple inheritance
also. Be warned that the design time envirionment [I was informed , i
have not even tried] for c# may make you cry for ..mummy!..

I'm certain that I'm correct in saying that the .Net framework itself
doesn't offer multiple inheritance, which means that C# (just like VB.Net)
doesn't support multiple inheritance. The only thing you can do is implement
multiple interfaces or use multiple levels of single-inheritance objects, as
already described.

--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #9
Mahesh,
C# does not have multiple inheritance of classes! Period.

C# does allow you to implement multiple interfaces just as VB.NET does.

The "problem" is that C# uses the same syntax for implementing an Interface
& Inheriting a class, namely the colon character ":" where as VB.NET uses
the cleaner, well at least more obvious, syntax of "Inherits" and
"Implements " to indicate you are implementing an interface verses inheriting
a class.
If you want true Multiple Inheritance of classes within .NET, then I would
recommend using Eiffel.NET (http://www.eiffel.com/), however I understand
that the multiple inheritance is only within Eiffel classes, and not the
..NET classes that it is able to expose. I also understand that it uses a
syntax to the VB.NET Implements syntax to avoid a couple of pitfalls of
Multiple Inheritance...

Hope this helps
Jay

"Mahesh Naik" <sh****@vsnl.co m> wrote in message
news:d7******** *************** **@posting.goog le.com...
Use the relatively cleaner and newer language from the devil. Use C #.
It has all that Vb.net offers as a language and multiple inheritance
also. Be warned that the design time envirionment [I was informed , i
have not even tried] for c# may make you cry for ..mummy!..

<<snip>>
Nov 21 '05 #10

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

Similar topics

2
4340
by: Graham Banks | last post by:
Does using multiple inheritance introduce any more performance overhead than single inheritance?
22
23390
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete examples?
2
1645
by: yaniv.golan | last post by:
Hi, Either I am missing something, or there is a compiler bug in the way inheritance from generic s is treated. In the following code, class c2 inherits from c1_generic. c1_generic has T as a generic paramter, and in the inheritance, class c2 specifies c3_T as the value of this parameter. class c1_generic defines 2 constructors, 1 of them taking 1 parameter.
1
1193
by: tony | last post by:
Hello!! Below I have some methods that first setup a select string then read the dataset into a ArrayList. I have used the Data Adaper ConfigurationWizard for these adapter that I use here. I just wonder if it's possible to use inheritance and polymorfism or some other construction here to minimize that code.
4
1790
by: Mountain | last post by:
Background: In trees, there are a two or three ways (maybe more) to find out if Node A is an ancestor of Node B without traversing the tree. Preprossing is OK, and one of the solutions I am aware of is here: "Use pre- and post-order numbers. Na is an ancestor of Nb iff pre(Na) < pre(Nb) and post(Na) > post(Nb)." See
6
3832
by: Bart Simpson | last post by:
I remember reading on parashift recently, that "Composition is for code reuse, inheritance is for flexibility" see (http://www.parashift.com/c++-faq-lite/smalltalk.html#faq-30.4) This confused me somewhat as I have always thought you get code reuse "for free" with inheritance. Am I missing something?. Will someone care to explain ??
21
2486
by: raylopez99 | last post by:
Well, contrary to the implication in my 2000 textbook on C# (public beta version), C# does allow multiple inheritance, so long as it's serially chained as follows: class derived02 : derived01 { } class derived01 : baseclass01
0
914
by: mahesh kumar | last post by:
Directly the c# doesn’t support the multiple inheritance , but multiple interfaces can be allowed… Like Public class myTest : IDisplay , IPrint { }
6
1369
by: Peng Yu | last post by:
Hi, I want B has all the constructors that A has. Obviously, the code below would not work. I could define a corresponding B's constructor for each A's constructor. But if A has many constructors, it would be inconvenient. I'm wondering if there is any way to inherent all A's constructor implicitly. Thanks, Peng
0
10600
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10354
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10097
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9175
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6867
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5535
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3835
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.