Diamond inheritance problem

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Diamond inheritance problem

Re: Diamond inheritance problem

Post by Philotheou » 19 Feb 2024, 12:43

https://stackoverflow.com/questions/2659116/how-does-virtual-inheritance-solve-the-diamond-multiple-inheritance-ambiguit

If your shared-base class isn't virtual then you will have 2 copies in memory ... and there's no good way to say which copy you want to access.

If your shared-base class is virtual then you will have only 1 copy in the inheritance diagram and then you can access its members as with any base member.

HTH...

Diamond inheritance problem

Post by kazhafeizhale » 25 Sep 2023, 03:05

I have a diamond inheritance problem here,For the gcc compiler, how do I access the members of the base class
image.png
image.png (183.19 KiB) Viewed 1031 times

Top