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. 9 1717
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.
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.
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****@discussions.microsoft.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.
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.
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.Customer.Name = "Jay"
invoice.Customer.Address = "Everywhere"
invoice.Order.Amount = $1
Hope this helps
Jay
"bob taylor" <bob ta****@discussions.microsoft.com> wrote in message
news:13**********************************@microsof t.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.
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******@discussions.microsoft.com> wrote in message news:<1A**********************************@microso ft.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.
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
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.
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.com> wrote in message
news:d7*************************@posting.google.co m... 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>> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Graham Banks |
last post by:
Does using multiple inheritance introduce any more performance overhead than
single inheritance?
|
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...
|
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...
|
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.
...
|
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...
|
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...
|
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
{...
|
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
{
}
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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...
|
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...
| |