Topic: using declarations and base classes
Author: Thanatos <fvali@biotrack.com>
Date: 1999/01/10 Raw View
After my readings of certain sections of the Standard and of a post
by a very well respected member of the C++ community ( dated 1/97 ), I
came to certain conclusions (and some undecidedness)
that I present as comments within the following code fragments.
What are your thoughts, if any, on my conclusions?
I include some references from the Standard at the end of this post,
although they might not be enough.
struct A
{
void f();
void v();
void v2();
struct InA
{
struct DeeperInA { };
};
private:
void p();
};
struct B : A
{
using A::v2;
void v( int );
void v2( int );
};
struct C : B
{
// Grammar seems to allow this, and the name is visible from
// the direct base class B, so it is well-formed
using B::A::f;
// well-formed if it replaces the above declaration
// A::f is clearly visible in the scope of B
// and f is a member of a base class of C
using A::f;
// unsure - A::v is hidden by B::v and since we don't bring A::v
// into scope, this name is hidden from client code accessing
// v from a pointer to or object of type B or derived from B.
// So v() is not visible in the scope of B as an unqualified name.
// v( int ) is found, and no further scopes are searched.
// Is this well-formed?
// (I lean towards no)
using A::v;
// if A::v is well-formed, can this declaration co-exist with A::v?
// (if A::v is well-formed, I lean towards yes)
using B::v;
using A::v2; // well-formed, since we brought it into B's scope
using B::v2; // well-formed, and should co-exist with A::v2
using B::p; // ill-formed
// if well-formed, it obviates
// typedef A::InA::DeeperInA DeeperInA;
// But I don't think this is well-formed, since DeeperInA is not
// visible as an unqualified name int he scope of B
using A::InA::DeeperInA;
};
Can you think of any others interesting cases?
Thanks in advance,
-fais
In 7.3.3 of the C++ Standard