Two-phase question: Is there a more synthetic way to write this code, i.e. Avoid all of these directives using? Something like using CBase<T>;this is what I would like, but it is not accepted.
#include <iostream>
template <typename T>
class CBase
{
protected:
int a, b, c, d;
public:
CBase() {
a = 123; c = 0;
}
};
template <typename T>
class CDer : public CBase<T>
{
using CBase<T>::a;
using CBase<T>::b;
public:
CDer() {
std::cout << a << this->c;
}
};
int main()
{
CDer<int> cd;
}
There are many more member variables / functions in my real code, and I was wondering if it is possible to write shorter code in some way.
Of course, using syntax this->cdoes not solve the problem ...
Thank you in!
gcc 4.1 macOS x 10.6
source
share