Two-phase lookup: can I avoid "code bloat"?
- by Pietro
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