相关疑难解决方法(0)

如何将结构模板标记为朋友?

我有这样的代码:

template <typename T, typename U> struct MyStruct {
    T aType;
    U anotherType;
};

class IWantToBeFriendsWithMyStruct
{
    friend struct MyStruct; //what is the correct syntax here ?
};
Run Code Online (Sandbox Code Playgroud)

为模板提供友谊的正确语法是什么?

c++ syntax templates class friend

11
推荐指数
2
解决办法
6599
查看次数

标签 统计

c++ ×1

class ×1

friend ×1

syntax ×1

templates ×1