What is inheritance by value and inheritance by reference?

Someone just asked me this question, but I'm a C # programmer, and I only know about class inheritance ... Interestingly, this thing is only for C / C ++? Is inheritance a reference a reference, we create a ClassA, and a ClassB inherited from this ClassA? Actually, what is it?

===== Change to make it clear:

Here is the question my friend got and he was doing a C programming test:

"There are two types of inheritance: inheritance by value and inheritance by reference. Show how to design a class to implement inheritance by reference" 

So, I suppose this should be related to C / C ++ ... But I have never heard of inheritance by value and inheritance by reference. But, as Bn said in the message, I only heard about passing by value and passing by reference ... Or maybe I'm wrong? Because I'm a C # programmer, so I really don't know about C / C ++ stuff ...

thanks

+4
source share
2 answers

I have not heard of this term regarding C or C ++. Perhaps you have one of two concepts?

  • Follow the link and follow the value.
  • Inheritance of implementation and inheritance of interfaces.

Perhaps another example will help determine the definition or source in which you heard that the terms used will be useful.

+5
source

I agree that the question is poorly worded (unless the context is indicated in the original post). Having said that, it is possible that the question relates to virtual and non-virtual inheritance.

C ++ virtual inheritance is useful because of the support for multiple inheritance languages โ€‹โ€‹(and the occurrence of various problems) See the diamond problem for a good explanation of this topic.

Hope this helps.

+1
source

All Articles