Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. multiple inheritance

multiple inheritance

Scheduled Pinned Locked Moved C#
csharpoopquestioncareer
24 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K kalyan_2416

    hi all i have searched in google few times i am not getting rather i am not understanding y it is not there in c# and there in vb how is the same possible in the case of interface i go to an interview get in to problems with this question.. thanking u

    C Offline
    C Offline
    Christian Graus
    wrote on last edited by
    #6

    You're kidding - VB.NET has multiple inheritance ?

    Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

    1 Reply Last reply
    0
    • S seeitsharper

      The fundermental problem is there is a chance that a class can alter the behaviour (override) of a method in a base class. Now if 2 classes do this (override the same base class) and you inherit both these classes then you can have a situation where you dont know which implementation of that method you are calling. There are other issues, but that is the one I can explain in the shortest amount of text. -- oh and as far as interfaces go; as the interface does not define the implementation of the method, it is fine to implement multiple interfaces.


      Keep your eyes open, you might spot alternatives.

      K Offline
      K Offline
      kalyan_2416
      wrote on last edited by
      #7

      thanx a lot i got it by a small exp. from ur explanations thax bye

      1 Reply Last reply
      0
      • K kalyan_2416

        hi all i have searched in google few times i am not getting rather i am not understanding y it is not there in c# and there in vb how is the same possible in the case of interface i go to an interview get in to problems with this question.. thanking u

        C Offline
        C Offline
        Colin Angus Mackay
        wrote on last edited by
        #8

        kalyan_2416 wrote:

        i am not understanding y it is not there in c# and there in vb

        I doubt that VB.NET has multiple inheritance because it is a limitation of the CLR rather than the language.


        -- Always write code as if the maintenance programmer were an axe murderer who knows where you live. Upcoming FREE developer events: * Glasgow: Agile in the Enterprise Vs. ISVs, Mock Objects, SQL Server CLR Integration, Reporting Services, db4o ... * Reading: SQL Bits My website

        C M 2 Replies Last reply
        0
        • S seeitsharper

          The fundermental problem is there is a chance that a class can alter the behaviour (override) of a method in a base class. Now if 2 classes do this (override the same base class) and you inherit both these classes then you can have a situation where you dont know which implementation of that method you are calling. There are other issues, but that is the one I can explain in the shortest amount of text. -- oh and as far as interfaces go; as the interface does not define the implementation of the method, it is fine to implement multiple interfaces.


          Keep your eyes open, you might spot alternatives.

          M Offline
          M Offline
          Martin 0
          wrote on last edited by
          #9

          Hello,

          seeitsharper wrote:

          Now if 2 classes do this (override the same base class) and you inherit both these classes then you can have a situation where you dont know which implementation of that method you are calling.

          If you are using Interfaces in a bad designed project (like seen here[^]), you could have simmilar problems.

          All the best, Martin

          C K S 3 Replies Last reply
          0
          • M Martin 0

            Hello,

            seeitsharper wrote:

            Now if 2 classes do this (override the same base class) and you inherit both these classes then you can have a situation where you dont know which implementation of that method you are calling.

            If you are using Interfaces in a bad designed project (like seen here[^]), you could have simmilar problems.

            All the best, Martin

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #10

            Yes, the core problem is bad design, which is why C# should support MI, because it can be very useful in good designs.

            Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

            M 1 Reply Last reply
            0
            • C Colin Angus Mackay

              kalyan_2416 wrote:

              i am not understanding y it is not there in c# and there in vb

              I doubt that VB.NET has multiple inheritance because it is a limitation of the CLR rather than the language.


              -- Always write code as if the maintenance programmer were an axe murderer who knows where you live. Upcoming FREE developer events: * Glasgow: Agile in the Enterprise Vs. ISVs, Mock Objects, SQL Server CLR Integration, Reporting Services, db4o ... * Reading: SQL Bits My website

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #11

              That's what I thought, too.

              Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

              K 1 Reply Last reply
              0
              • C Christian Graus

                That's what I thought, too.

                Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                K Offline
                K Offline
                kalyan_2416
                wrote on last edited by
                #12

                my mistake sorry...!

                C 1 Reply Last reply
                0
                • K kalyan_2416

                  my mistake sorry...!

                  C Offline
                  C Offline
                  Christian Graus
                  wrote on last edited by
                  #13

                  That's cool, I was just interested, because if you were right, it meant I was learning something for the night :-)

                  Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                  1 Reply Last reply
                  0
                  • C Christian Graus

                    Yes, the core problem is bad design, which is why C# should support MI, because it can be very useful in good designs.

                    Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                    M Offline
                    M Offline
                    Martin 0
                    wrote on last edited by
                    #14

                    Christian Graus wrote:

                    which is why C# should support MI, because it can be very useful in good designs

                    Can be said loud and proud!!

                    All the best, Martin

                    P 1 Reply Last reply
                    0
                    • M Martin 0

                      Hello,

                      seeitsharper wrote:

                      Now if 2 classes do this (override the same base class) and you inherit both these classes then you can have a situation where you dont know which implementation of that method you are calling.

                      If you are using Interfaces in a bad designed project (like seen here[^]), you could have simmilar problems.

                      All the best, Martin

                      K Offline
                      K Offline
                      kalyan_2416
                      wrote on last edited by
                      #15

                      class c { void i1.function_some() { // body } void i2.function_some() { // body } } class c1:c { c dd =new c(); i1 i=(i1)dd; i.funcion_some();-----gets the function of interface i1 in class c i2 i_d=new c(); i_d.function_some();---gets the function of interface i2 in class c with the help of type casting i can get the individual definition of the functions } i think this will lead to some ambguity...!

                      1 Reply Last reply
                      0
                      • C Colin Angus Mackay

                        kalyan_2416 wrote:

                        i am not understanding y it is not there in c# and there in vb

                        I doubt that VB.NET has multiple inheritance because it is a limitation of the CLR rather than the language.


                        -- Always write code as if the maintenance programmer were an axe murderer who knows where you live. Upcoming FREE developer events: * Glasgow: Agile in the Enterprise Vs. ISVs, Mock Objects, SQL Server CLR Integration, Reporting Services, db4o ... * Reading: SQL Bits My website

                        M Offline
                        M Offline
                        Martin 0
                        wrote on last edited by
                        #16

                        Again, a stupid downvoter on your side! What are you doing to people here? Are you sending spam mails over your account, or is it rude for somebody that you try to help? Got my 5

                        All the best, Martin

                        K C 2 Replies Last reply
                        0
                        • C Christian Graus

                          That's just plain retarded, IMO. But the big question is, does VB really allow it ?

                          Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                          S Offline
                          S Offline
                          seeitsharper
                          wrote on last edited by
                          #17

                          Christian Graus wrote:

                          That's just plain retarded

                          Really, I hope you are not refering to my example. I was trying to raise a point about it.


                          Keep your eyes open, you might spot alternatives.

                          1 Reply Last reply
                          0
                          • M Martin 0

                            Hello,

                            seeitsharper wrote:

                            Now if 2 classes do this (override the same base class) and you inherit both these classes then you can have a situation where you dont know which implementation of that method you are calling.

                            If you are using Interfaces in a bad designed project (like seen here[^]), you could have simmilar problems.

                            All the best, Martin

                            S Offline
                            S Offline
                            seeitsharper
                            wrote on last edited by
                            #18

                            No, the point I was making was that you are inheriting behaviour. Interfaces have no behviour thus the problem is different. I agree on the what constitutes Good and bad design and perhaps Microsoft could have came up with a MI solution that worked.


                            Keep your eyes open, you might spot alternatives.

                            1 Reply Last reply
                            0
                            • M Martin 0

                              Again, a stupid downvoter on your side! What are you doing to people here? Are you sending spam mails over your account, or is it rude for somebody that you try to help? Got my 5

                              All the best, Martin

                              K Offline
                              K Offline
                              kalyan_2416
                              wrote on last edited by
                              #19

                              i m sorry for that i happy for the response.. i am here to learn... i am not rude on anyone as such!!!!!!!!!!

                              M 1 Reply Last reply
                              0
                              • K kalyan_2416

                                i m sorry for that i happy for the response.. i am here to learn... i am not rude on anyone as such!!!!!!!!!!

                                M Offline
                                M Offline
                                Martin 0
                                wrote on last edited by
                                #20

                                Got my 5 for that! :rose:

                                All the best, Martin

                                1 Reply Last reply
                                0
                                • M Martin 0

                                  Christian Graus wrote:

                                  which is why C# should support MI, because it can be very useful in good designs

                                  Can be said loud and proud!!

                                  All the best, Martin

                                  P Offline
                                  P Offline
                                  PIEBALDconsult
                                  wrote on last edited by
                                  #21

                                  Perhaps in an unsafe context? :-D Meaning only that unsafe indicates to the compiler, "I know what I'm doing, let me through." Hmmm... maybe unsafe could also be used to allow fall-through in switches...

                                  M 1 Reply Last reply
                                  0
                                  • P PIEBALDconsult

                                    Perhaps in an unsafe context? :-D Meaning only that unsafe indicates to the compiler, "I know what I'm doing, let me through." Hmmm... maybe unsafe could also be used to allow fall-through in switches...

                                    M Offline
                                    M Offline
                                    Martin 0
                                    wrote on last edited by
                                    #22

                                    :) I realy enjoy reading, when you are talking to yourself. Like this one[^]!

                                    All the best, Martin

                                    P 1 Reply Last reply
                                    0
                                    • M Martin 0

                                      :) I realy enjoy reading, when you are talking to yourself. Like this one[^]!

                                      All the best, Martin

                                      P Offline
                                      P Offline
                                      PIEBALDconsult
                                      wrote on last edited by
                                      #23

                                      Glad to be of service. :-D

                                      1 Reply Last reply
                                      0
                                      • M Martin 0

                                        Again, a stupid downvoter on your side! What are you doing to people here? Are you sending spam mails over your account, or is it rude for somebody that you try to help? Got my 5

                                        All the best, Martin

                                        C Offline
                                        C Offline
                                        Colin Angus Mackay
                                        wrote on last edited by
                                        #24

                                        Martin# wrote:

                                        What are you doing to people here?

                                        I have no idea. I can only guess that I gave someone some advice they didn't actually want to hear.


                                        -- Always write code as if the maintenance programmer were an axe murderer who knows where you live. Upcoming FREE developer events: * Glasgow: Agile in the Enterprise Vs. ISVs, Mock Objects, SQL Server CLR Integration, Reporting Services, db4o ... * Reading: SQL Bits My website

                                        1 Reply Last reply
                                        0
                                        Reply
                                        • Reply as topic
                                        Log in to reply
                                        • Oldest to Newest
                                        • Newest to Oldest
                                        • Most Votes


                                        • Login

                                        • Don't have an account? Register

                                        • Login or register to search.
                                        • First post
                                          Last post
                                        0
                                        • Categories
                                        • Recent
                                        • Tags
                                        • Popular
                                        • World
                                        • Users
                                        • Groups