Alex Rivera | Logout

"using" keyword for base class variable

Asked 2011-06-13T22:24:28.400
13

I am going over the WildMagic 5 engine (www.geometrictools.com) where the Vector<> class is inheriting from a Tuple<> class which has an array of a particular size, named mTuple[] (set by a template parameter). So far so good, nothing special. In the Vector class however, I see the following:

protected:
    using Tuple<4,Real>::mTuple; 

Now I know that the using keyword is used for inheriting overloaded methods properly. In this case, I always assumed the variable was available to the derived class without typing the above code. Is the above necessary? Or is it just there to make things clearer?

Edit
Report

1 Answer

1

Normally, you can use a declaration like this to increase the access of an inherited member. Say from protected to public.

But you cannot use this syntax to restrict access. And you cannot use it on a member declared private.

So the only time this could do anything is if Vector inherits from Tuple<> like so:

class Vector4 : private Tuple<4,Real>
{ ... }

In that case, this using declaration would make mTuple protected instead of private.

In all other cases, it will do nothing, I believe.

[edit]

And my belief was wrong where template base classes are concerned. See the answers from Johannes and David.

answered 2011-06-13T22:40:24.997

Your Answer