i have seen an inheritance statement like this
className : virtual public anotherClassName
what does virtual mean there?
i have seen an inheritance statement like this
className : virtual public anotherClassName
what does virtual mean there?
It's to solve the diamond inheritance problem where you have a base class, then 2 child classes then a 4th class that inherits from both of the previous classes. If the base class declares a function then there is ambiguity of that function in the 4th class. Declaring the 2 child classes as inheriting virtually will allow the implementation of the base class's to fall through to the 4th class.
See, for example: http://en.wikipedia.org/wiki/Virtual_inheritance
So class className is a suitable player for "diamond" inheritance.
See, for example: http://en.wikipedia.org/wiki/Virtual_inheritance
So class className is a suitable player for "diamond" inheritance.
Yeah, that's a bit easier to follow than what I said but essentially the same :)
thank you guys i have read it before, but this is the first time i see it in action.
being able to inherit from more than one classes does not seem to be useful, that might be why it is not possible in C# or JAVA
being able to inherit from more than one classes does not seem to be useful, that might be why it is not possible in C# or JAVA
Heh, that's a whole 'nother thread to talk about the benefits, caveats and downfalls of multiple inheritance. Suffice it to say that it's definitely a bonus that C++ has it (sometimes)
being able to inherit from more than one classes does not seem to be useful, that might be why it is not possible in C# or JAVA
Well, Money == Evil, that's why there are lots of paupers in the World ;)...
Well, Money == Evil, that's why there are lots of paupers in the World ;)...
i didnt get it :( (probably language deficiency)
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.