C++ 在嵌套的C+内复制typedef+;班
是否有更好的方法在嵌套类中声明相同的typedef,或者有其他方法使该类型可以从嵌套类访问C++ 在嵌套的C+内复制typedef+;班,c++,class,typedef,C++,Class,Typedef,是否有更好的方法在嵌套类中声明相同的typedef,或者有其他方法使该类型可以从嵌套类访问 class A { public: typedef vector<vector<int> >::const_iterator const_it; class B { public: //regular way with code redundancy typedef vector<vector<int> &g
class A {
public:
typedef vector<vector<int> >::const_iterator const_it;
class B {
public:
//regular way with code redundancy
typedef vector<vector<int> >::const_iterator const_it;
};
};
int main() {
A::const_it it1;
A::B::const_it it2;
return 0;
}
A类{
公众:
typedef vector::const_迭代器const_it;
B类{
公众:
//具有代码冗余的常规方法
typedef vector::const_迭代器const_it;
};
};
int main(){
A::const_it it1;
A::B::const_it it2;
返回0;
}
注意:我知道const_it可以从B中看到,但我想通过B从外部访问它(例如A::B::const_it)我发现
typedef A::const_it const_在类B
的定义中,code>比您的typedef
更容易接受提示:A::const\u它在B
中可见,是的,我知道,但您不能通过B访问它(例如A::B::const\u it)