Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Member lookup rules are defined in Section 10.2/2</p> <blockquote> <p>The following steps define the result of name lookup in a class scope, <code>C</code>. First, every declaration for the name in the class and in each of its base class sub-objects is considered. A member name <code>f</code> in one sub-object <code>B</code> hides a member name <code>f</code> in a sub-object <code>A</code> if <code>A</code> is a base class sub-object of <code>B</code>. <strong>Any declarations that are so hidden are eliminated from consideration</strong>. Each of these declarations that was introduced by a using-declaration is considered to be from each sub-object of <code>C</code> that is of the type containing the declara-tion designated by the using-declaration. <strong>If the resulting set of declarations are not all from sub-objects of the same type, or the set has a nonstatic member and includes members from distinct sub-objects, there is an ambiguity and the program is ill-formed</strong>. Otherwise that set is the result of the lookup.</p> </blockquote> <pre><code>class A { public: int f(int); }; class B { public: int f(); }; class C : public A, public B {}; int main() { C c; c.f(); // ambiguous } </code></pre> <p>So you can use the <code>using</code> declarations <code>A::f</code> and <code>B::f</code> to resolve that ambiguity</p> <pre><code>class C : public A, public B { using A::f; using B::f; }; int main() { C c; c.f(); // fine } </code></pre> <p>The second code works flawlessly because <code>void foo(float)</code> is inside C's scope. Actually <code>d.foo(5);</code> calls <code>void foo(float)</code> and not the <code>int</code> version.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload