テンプレート派生クラスB
のメソッドで、テンプレート基本クラスA
で定義されている属性を使用します。
これまでのところ、using
の作品が見つかりました。
A
という単一の属性ごとにusing
ステートメントを書くのは面倒です。
どうすればusing
文がたくさん書くのを避けることができますか?"使用しない"テンプレートベースクラスのアクセス属性
#include <iostream>
using namespace std;
template <typename T>
class A{
public:
A(){
a = 10;
}
//virtual destructor
virtual ~A(){
cout << "~A() is called" << endl;
}
protected:
T a;
} ;
template <typename T>
class B : public A<T>{
public:
void f(void){
cout << a << endl;
}
virtual ~B(){
cout << "~B() is called" << endl;
}
private:
using A<T>::a; //how to get rid of this?
} ;
int main(void){
B<int> bb;
bb.f();
}
* "これを取り除く方法[使用]" *:by ** 'this'^_ ^ – Jarod42