There is following c++ raw code:
template<typename T>
class A {
private:
// here I want to access B::SomeStruct to create SomeStruct field in class A
};
template<typename T>
class B {
private:
template<typename Tp>
friend class A;
struct SomeStruct {
void some_field;
};
};
In class A I want to create a field with the type of SomeStruct
- struct declared in class B as a private member. Does it even possible?
Restrictions:
This would be one way. All B
:s befriends all A
:s and A<T>
has a B<T>::SomeStruct
member:
template<typename T>
class B {
private:
template<typename Tp>
friend class A;
struct SomeStruct {};
};
template<typename T>
class A {
private:
// 'typename' prior to dependent type name 'B<T>::SomeStruct':
typename B<T>::SomeStruct ss;
};