Diamond inheritance problem

Talk about things C/C++, some related to AutoHotkey
kazhafeizhale
Posts: 77
Joined: 25 Dec 2018, 10:58

Diamond inheritance problem

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 913 times
Philotheou
Posts: 2
Joined: 19 Feb 2024, 12:41

Re: Diamond inheritance problem

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...

Return to “C/C++”

Who is online

Users browsing this forum: No registered users and 47 guests