Page 1 of 1

Diamond inheritance problem

Posted: 25 Sep 2023, 03:05
by kazhafeizhale
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 1085 times

Re: Diamond inheritance problem

Posted: 19 Feb 2024, 12:43
by Philotheou
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...