Re: Templates, inheritance and variable visibility
On Apr 4, 2:49 am, Ian Collins <ian-n...@hotmail.com> wrote:
Alf P. Steinbach wrote:
The definition or existence of 'a_' depends on template parameter.
You have to tell the compiler in some way, by qualification
or 'using', that it comes from the base class and is not
from an enclosing scope.
Exactly why that rule was chosen instead of the for C++98
more reasonable of having to qualify use of enclosing scope
names is a mystery.
To you and me both. Although James has cited some corner
cases where it does make sense, I'm still not convinced. It
leads to some pretty ugly and unnecessarily verbose code.
I'm not sure which cases you're referring to, and if I did, it
was just citing the arguments of others. My own personal
opinion is:
-- The distinction between dependent and non-dependent names is
not necessary. I know the problem it is trying to solve,
but in my experience, it's not a serious problem in well
written code, and the extra complexity makes the cost of the
solution higher than the cost of the problem.
-- *If* you're going to introduce a distinction between
dependent and non-dependent names, then it should be done
explicitly, e.g. with a special declaration at the start of
the template, stating which names are dependent, rather than
depending on subtle issues of syntax (this->a vs. a) to make
the distinction.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34