1

I understand that when I create the dreaded diamond

struct Base { void foo() { } };
struct A: Base { };
struct B: Base { };
struct AB: A, B { };

The memory representation is

Base Base
|    |
A    B
 \  /
  AB

so calling AB ab; ab.foo(); causes ambiguosity problem. But when I hide the foo from one branch

struct Base { void foo() { } };
struct A: Base { private: using Base::foo; };
struct B: Base { };
struct AB: A, B { };

there should be just one accessible foo in ab, yet the ambiguosity is still there. What am I missing?

Pete Becker
  • 74,985
  • 8
  • 76
  • 165
Jan Turoň
  • 31,451
  • 23
  • 125
  • 169
  • 5
    @πάντα ῥεῖ - What answer in the linked questions discusses accessibility? None of those addresses what the OP wants to really know about. You are being somewhat trigger happy. – StoryTeller - Unslander Monica Aug 20 '18 at 11:25
  • @Story I'd like to see research efforts from an OP, and see what actually makes the point of their confusion. In regards of urging that, I am trigger happy, yes. – πάντα ῥεῖ Aug 20 '18 at 11:33
  • 2
    @StoryTeller - I suppose one of us can use our vote to counter the close hammer. The answer is fairly simple, as I'm sure you realise. If you're happy to post an answer, I'll vote to open (avoids actual/perceived conflict of interest in voting to open, in order to post). – Peter Aug 20 '18 at 11:33
  • 1
    Anyway. Took me some time, but I did find the proper duplicate. Now edited it in. – StoryTeller - Unslander Monica Aug 20 '18 at 11:33
  • 2
    @Peter - I'm not contenting that it's a dupe. But I think it's not very even handed to close with an unrelated dupe just because. – StoryTeller - Unslander Monica Aug 20 '18 at 11:34
  • 1
    @StoryTeller - I tend to agree. If I'm not happy with the apparent research effort in a question, I find a way to say that in the process of closing, even if I have to use "other". – Peter Aug 20 '18 at 11:35
  • 1
    @StoryTeller - there's a bit more to the dup you identified than this question. But I agree the last paragraph of the answer (by Cubbi) does answer this question. – Peter Aug 20 '18 at 11:40
  • @πάνταῥεῖ what do you like or not is irrelevant here: I made my effort to narrow my problem in the code, to show that I get the point of dreaded diamond to avoid automatic answers of those not reading properly. Please don't abuse your instant close privilege next time. You event didn't bothered to comment the simple answer. – Jan Turoň Aug 20 '18 at 11:41
  • @StoryTeller thank you for the proper duplicate. Is the order of evaluating "finding same name, then best match, then check accessibility" defined in standard or is it compiler dependent? – Jan Turoň Aug 20 '18 at 11:44
  • 2
    @JanTuroň - Standard mandated https://timsong-cpp.github.io/cppwp/n4659/class.access#5 – StoryTeller - Unslander Monica Aug 20 '18 at 11:46
  • There's no diamond. – ROX Aug 20 '18 at 11:58

0 Answers0