本文介绍了如何将结构模板标记为朋友?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样的代码:
template <typename T, typename U> struct MyStruct {
T aType;
U anotherType;
};
class IWantToBeFriendsWithMyStruct
{
friend struct MyStruct; //what is the correct syntax here ?
};
向模板提供友谊的正确语法是什么?
What is the correct syntax to give friendship to the template ?
推荐答案
class IWantToBeFriendsWithMyStruct
{
template <typename T, typename U>
friend struct MyStruct;
};
在VS2008中有效,并允许MyStruct访问该类。
Works in VS2008, and allows MyStruct to access the class.
这篇关于如何将结构模板标记为朋友?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!