multiple inheritance
-
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
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 )
-
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.
thanx a lot i got it by a small exp. from ur explanations thax bye
-
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
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
-
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.
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
-
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
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 )
-
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
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 )
-
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 )
my mistake sorry...!
-
my mistake sorry...!
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 )
-
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 )
-
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
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...!
-
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
-
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 )
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.
-
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
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.
-
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
i m sorry for that i happy for the response.. i am here to learn... i am not rude on anyone as such!!!!!!!!!!
-
i m sorry for that i happy for the response.. i am here to learn... i am not rude on anyone as such!!!!!!!!!!
-
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
Perhaps in an
unsafe
context? :-D Meaning only thatunsafe
indicates to the compiler, "I know what I'm doing, let me through." Hmmm... maybeunsafe
could also be used to allow fall-through inswitch
es... -
Perhaps in an
unsafe
context? :-D Meaning only thatunsafe
indicates to the compiler, "I know what I'm doing, let me through." Hmmm... maybeunsafe
could also be used to allow fall-through inswitch
es... -
Glad to be of service. :-D
-
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
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