Multiple inheritence? 
Author Message
 Multiple inheritence?

Did I hear somewhere what VB.Net won't support multiple inheritance? So two
Inherits in a class won't be allowed?

Cheers, Rob.



Mon, 09 Jun 2003 01:05:41 GMT  
 Multiple inheritence?
Rob,

Quote:
> Did I hear somewhere what VB.Net won't support multiple inheritance? So
two
> Inherits in a class won't be allowed?

That's correct. The .NET object model only supports single inheritance, so
neither C# not MC++ support it. You can still implement multiple interfaces,
though, like in Java.

--
Tomas Restrepo [VC++ MVP]

http://www.mvps.org/windev/



Mon, 09 Jun 2003 01:56:14 GMT  
 Multiple inheritence?

Quote:
>You can still implement multiple interfaces, though, like in Java.

And an interface can derive from multiple base interfaces.

Matt

============================================



Mon, 09 Jun 2003 02:06:28 GMT  
 Multiple inheritence?

Quote:
> And an interface can derive from multiple base interfaces.

Hmm, so let me get my head around this. In C++, I can do things like:

public AdverseEvent : public Object, public Procedure
{
// etc

Quote:
};

In that AdverseEvent inherits both the members from Object and Procedure.

This isn't allowed in .NET?

Cheers, Rob.



Mon, 09 Jun 2003 02:28:13 GMT  
 Multiple inheritence?

Quote:
>public AdverseEvent : public Object, public Procedure
>This isn't allowed in .NET?

Not in managed code (using the CLR). However, you can still write
unmanaged C++ code with all the C++ horrors using VS.NET if you want.


Mon, 09 Jun 2003 02:37:15 GMT  
 Multiple inheritence?

Quote:
> Not in managed code (using the CLR). However, you can still write
> unmanaged C++ code with all the C++ horrors using VS.NET if you want.

What's so bad about multiple inheritance?

Rob.



Mon, 09 Jun 2003 03:22:10 GMT  
 Multiple inheritence?

Quote:
> What's so bad about multiple inheritance?

Inherently, not all that much. It just opens up a whole new world of
coding errors and bugs. Most new languages intentionally do not
support it.


Mon, 09 Jun 2003 03:29:31 GMT  
 Multiple inheritence?
I don't know but MS don't allow it in the CLR. I think they should allow it
too.

- Marcus


Quote:
> > Not in managed code (using the CLR). However, you can still write
> > unmanaged C++ code with all the C++ horrors using VS.NET if you want.

> What's so bad about multiple inheritance?

> Rob.



Mon, 09 Jun 2003 03:29:33 GMT  
 Multiple inheritence?

Quote:
> What's so bad about multiple inheritance?

Naming clashes are a big thing. The Syntax to resolve them tends to be
atrocious.

MI is used mainly with abstract classes to show what the can do. Interfaces
take on this role in a more elegant fashion. For instance, the enumerator in
by Z-Tree works completely different from a standard B-Tree, so inheriting
Enumerator would be silly. However I still need the follow a contract in
order to communicate with the For Each structure. This is where interfaces
come into play. It describes what my class can do, not how it does it.

--
Jonathan Allen


Quote:
> > Not in managed code (using the CLR). However, you can still write
> > unmanaged C++ code with all the C++ horrors using VS.NET if you want.

> What's so bad about multiple inheritance?

> Rob.



Mon, 09 Jun 2003 03:57:49 GMT  
 Multiple inheritence?

Quote:

> > Not in managed code (using the CLR). However, you can still write
> > unmanaged C++ code with all the C++ horrors using VS.NET if you want.

> What's so bad about multiple inheritance?

Imagine you have three classes, A, B and C:

Class A {
  public doSomething( int )
  public doSomethingElse()

Quote:
}

Class B {
  public doSomething( int )
  public doYetAnotherThing()

Quote:
}

Class C Inherits From A, B

If you create an instance of C and then call doSomething() on that instance,
are you calling A.doSomething() or B.doSomething()?
--
Adam D. Barratt



Mon, 09 Jun 2003 06:40:26 GMT  
 Multiple inheritence?
    Yes, but in that instance, you'll get a compiler error with the infamous
"Ambiguity in function xxxx" at least in VC6++



Quote:

> > > Not in managed code (using the CLR). However, you can still write
> > > unmanaged C++ code with all the C++ horrors using VS.NET if you want.

> > What's so bad about multiple inheritance?

> Imagine you have three classes, A, B and C:

> Class A {
>   public doSomething( int )
>   public doSomethingElse()
> }

> Class B {
>   public doSomething( int )
>   public doYetAnotherThing()
> }

> Class C Inherits From A, B

> If you create an instance of C and then call doSomething() on that
instance,
> are you calling A.doSomething() or B.doSomething()?
> --
> Adam D. Barratt



Mon, 09 Jun 2003 07:24:25 GMT  
 Multiple inheritence?
Yes, that's a big problem because e.g. Dispose is a function that exists in
the most classes in the CLR.

Maybe we should type A.doSomething() instead of just doSomething()?

- Marcus

Quote:



> > > > Not in managed code (using the CLR). However, you can still write
> > > > unmanaged C++ code with all the C++ horrors using VS.NET if you
want.

> > > What's so bad about multiple inheritance?

> > Imagine you have three classes, A, B and C:

> > Class A {
> >   public doSomething( int )
> >   public doSomethingElse()
> > }

> > Class B {
> >   public doSomething( int )
> >   public doYetAnotherThing()
> > }

> > Class C Inherits From A, B

> > If you create an instance of C and then call doSomething() on that
> instance,
> > are you calling A.doSomething() or B.doSomething()?
> > --
> > Adam D. Barratt



Mon, 09 Jun 2003 08:46:01 GMT  
 Multiple inheritence?

Quote:
> Maybe we should type A.doSomething() instead of just doSomething()?

Yes, that's sensible. Isn't it A::doSomething() in C++ parlance?

Cheers, Rob



Tue, 10 Jun 2003 01:04:36 GMT  
 Multiple inheritence?

Quote:
> If you create an instance of C and then call doSomething() on that
instance,
> are you calling A.doSomething() or B.doSomething()?

The same can be said of every single name in the entire system. I create an
component Object called Wibble and you create another component called
Wibble. We reference them and do

dim MyObj as Wibble

Which object are we referring. Fully qualifying declarations is just name of
the game. Blocking MI just because of this sounds like a knee jerk reaction.

dim MyObj as RobNicholson.Wibble

isn't *that* bad is it?

The same with inheritence. If I have to write

inherits ClassA
inherits ClassB

ClassA.DoSomething
ClassB.DoSomething

It's not much different is it?

Cheers, Rob.



Tue, 10 Jun 2003 01:03:54 GMT  
 Multiple inheritence?
Quote:
> MI is used mainly with abstract classes to show what the can do.

Interfaces
 take on this role in a more elegant fashion. For instance, the enumerator
in

The problem I have with interfaces is that it creates an awful lot more
typing in VB (unless VB.Net is going to do this another way). In our system,
we have our own object and have a:

Implements IObject

In most classes. But then each object has to manually implement each of the
members with the not-so-nice syntax:

sub IObject_Save()

In most circumstances, we usually delegate a lot of the code in the
interface to a "helper" object that implements the code so we end up with:

private m_Object as new CObject

sub IObject_Save()
m_Object.Save
end sub

And if we decide to add, change or delete an interface, we have to go
through every object that users the interface. Not nice.

So at least we'll be able to inherit CObject in this case, but an object
often uses other interfaces/objects as well.

Cheers, Rob.

Quote:
> by Z-Tree works completely different from a standard B-Tree, so inheriting
> Enumerator would be silly. However I still need the follow a contract in
> order to communicate with the For Each structure. This is where interfaces
> come into play. It describes what my class can do, not how it does it.

> --
> Jonathan Allen



> > > Not in managed code (using the CLR). However, you can still write
> > > unmanaged C++ code with all the C++ horrors using VS.NET if you want.

> > What's so bad about multiple inheritance?

> > Rob.



Tue, 10 Jun 2003 01:08:35 GMT  
 
 [ 21 post ]  Go to page: [1] [2]

 Relevant Pages 

1. ActiveX inheritence problem

2. Problem with inheritence and localizability

3. Inheritence

4. IDE interferes with Inheritence

5. tool tips and inheritence

6. ADsSecurity and turning inheritence off

7. Folders and Permission Inheritence

8. disable inheritence from security tab

9. Inheritence in VB6

10. Class Inheritence in VB

11. Inheritence

12. Inheritence in VB

 

 
Powered by phpBB® Forum Software