4 Replies - 5653 Views - Last Post: 04 April 2013 - 11:30 AM

#1 Drowjam  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 33
  • Joined: 16-October 12

Multiple Inheritence

Posted 03 April 2013 - 08:57 PM

Ok so i just figure out how to have a multi_Inherit classes in vb. Its a simple trick using generics. basically is u us the of statment on a class u created that has its own inheritance and you can add in functionality to it. You could literally add as many inheritance heirachies to it as you want but it will become very confusing quickly best to just keep it simple.
Ok basic concept

Class Class1 

End Class
Class Class2 
Inherits Class1

end Class
Class Class3(OF T)
Public Value as T

End Class
Public C3 as Class3(Of Class2)


pretty simple, i wonder what would happen if both class3 and class2 inherited from class1.


Ok now lets add a 3rd inherit to our class
and you will see why it will quicly become very confusing
class Class4

end Class
class Class5(Of T)
Inherits Class4
End Class
Public MI as Class5(Of Class3(Of Class2))


I Hope it makes sense, Im not a Programmer this is kinda of a hobby for me. I dont know why u would want to do it but there it is.

Is This A Good Question/Topic? 0
  • +

Replies To: Multiple Inheritence

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8396
  • View blog
  • Posts: 31,234
  • Joined: 12-June 08

Re: Multiple Inheritence

Posted 03 April 2013 - 09:41 PM

I am a bit confused.. is this a tutorial on inheritance, or is there a question I missed?
Was This Post Helpful? 0
  • +
  • -

#3 Drowjam  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 33
  • Joined: 16-October 12

Re: Multiple Inheritence

Posted 03 April 2013 - 09:54 PM

View Postmodi123_1, on 03 April 2013 - 09:41 PM, said:

I am a bit confused.. is this a tutorial on inheritance, or is there a question I missed?

Lol sorry its not a tutorial, I just learned about this myself. since i dont really understand it that well myself i was hoping some smarter people than myself might explain what i was actually doing. i understand from more of a logical standpoint what im doing but on the tech side im pretty much clueless. I thought for once i had actually come up with something clever so i wanted to share with people and find out if it was really as clever as i thought it was.
Was This Post Helpful? 0
  • +
  • -

#4 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2216
  • View blog
  • Posts: 9,352
  • Joined: 29-May 08

Re: Multiple Inheritence

Posted 04 April 2013 - 11:08 AM

(Of T) is generics and has nothing to do with multiple inheritence.

With would be something like this, if it did support it.

Class Example1
End Class 

Class Example2
End Class

Class Example3
  Inherits Example2
  Inherits Example1
End Class



Was This Post Helpful? 0
  • +
  • -

#5 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 2890
  • View blog
  • Posts: 9,597
  • Joined: 12-December 12

Re: Multiple Inheritence

Posted 04 April 2013 - 11:30 AM

Multiple inheritence is not supported by design:

Quote

Chris Brumme, a distinguished engineer on the .NET team at the time, said this back in 2004:

There are several reasons we haven't provided a baked-in, verifiable, CLS-compliant version of multiple implementation inheritance:

Different languages actually have different expectations for how MI works. For example, how conflicts are resolved and whether duplicate bases are merged or redundant. Before we can implement MI in the CLR, we have to do a survey of all the languages, figure out the common concepts, and decide how to express them in a language-neutral manner. We would also have to decide whether MI belongs in the CLS and what this would mean for languages that don't want this concept (presumably VB.NET, for example). Of course, that's the business we are in as a common language runtime, but we haven't got around to doing it for MI yet.

The number of places where MI is truly appropriate is actually quite small. In many cases, multiple interface inheritance can get the job done instead. In other cases, you may be able to use encapsulation and delegation. If we were to add a slightly different construct, like mixins, would that actually be more powerful?

Multiple implementation inheritance injects a lot of complexity into the implementation. This complexity impacts casting, layout, dispatch, field access, serialization, identity comparisons, verifiability, reflection, generics, and probably lots of other places.

It's not at all clear that this feature would pay for itself. It's something we are often asked about. It's something we haven't done due diligence on. But my gut tells me that, after we've done a deep examination, we'll still decide to leave the feature unimplemented.

So trying to reproduce this feature seems, to me, counter-intuitive.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1