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 AI 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;
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.