当我使用模板时,“friend”函数出错。我不明白。请您帮我解释一下吗?
#include<iostream>
using namespace std;
template<class T>
class sophuc
{
public:
sophuc(T new_thuc, T new_ao);
void fill();
void Display();
sophuc();
friend sophuc sum_(sophuc &a, sophuc &b);
private:
T thuc, ao;
};
希望有人尽快解决我。
您可能希望将友元函数移动为私有,使其仅在声明类 sophuc 的类和函数中可用。