COM Interview Question
-
Suppose I derive Add and Multiply from IUnknown and then derive Calculator from Add and Multiply as shown below IUnknown IUnknown | | ADD Multiply \ / \ / Calculator then how many copies of (QueryInterface,AddRef, Release ) will be there in Calculator,If one then explain how. Prior to this question I had said that Multiple Inheritance has a disadvantage of name ambiguity.(hence above was the counter question by an interviewer)
-
Suppose I derive Add and Multiply from IUnknown and then derive Calculator from Add and Multiply as shown below IUnknown IUnknown | | ADD Multiply \ / \ / Calculator then how many copies of (QueryInterface,AddRef, Release ) will be there in Calculator,If one then explain how. Prior to this question I had said that Multiple Inheritance has a disadvantage of name ambiguity.(hence above was the counter question by an interviewer)
This question is not clear. In COM interfaces can only be derived from one base class.
IUnkown
is an interface.Calculator
clearly isn't a COM interface as it uses multiple inheritance. This suggests that this is an implementation hierarchy:Calculator
is a C++ class that is using multiple inheritance to implement COM interfaces. It's still not clear whatADD
andMultiply
are. Their names suggest they are not interfaces. This question is too vague. Steve -
This question is not clear. In COM interfaces can only be derived from one base class.
IUnkown
is an interface.Calculator
clearly isn't a COM interface as it uses multiple inheritance. This suggests that this is an implementation hierarchy:Calculator
is a C++ class that is using multiple inheritance to implement COM interfaces. It's still not clear whatADD
andMultiply
are. Their names suggest they are not interfaces. This question is too vague. Steve -
Then there is one implementation for each. This is how multiple inheritance works in C++. Steve