Two-phase lookup: can I avoid "code bloat"?

Posted by Pietro on Stack Overflow See other posts from Stack Overflow or by Pietro
Published on 2010-04-02T20:15:06Z Indexed on 2010/04/02 22:33 UTC
Read the original article Hit count: 389

Filed under:
|
|
|

Two-phase lookup question: Is there a more synthetic way to write this code, i.e. avoiding all those "using" directives? I tried with "using CBase<T>;", but it is not accepted.

#include <iostream>

template <typename T>
class CBase
{
protected:
    int a, b, c, d;   // many more...

public:
    CBase() {
        a = 123;
    }
};


template <typename T>
class CDer : public CBase<T>
{
//  using CBase<T>;     // error, but this is what I would like
    using CBase<T>::a;
    using CBase<T>::b;
    using CBase<T>::c;
    //...

public:
    CDer() {
        std::cout << a;
    }
};


int main()
{
    CDer<int> cd;
}

In my real code there are many more member variables/functions, and I was wondering if it is possible to write shorter code in some way.
Of course, using the CBase::a syntax does not solve the problem...

Thank's!


gcc 4.1 MacOS X 10.6

© Stack Overflow or respective owner

Related posts about phase

Related posts about lookup