使用模板 C++ 的友元函数语法错误
error in friend function syntax using templates c++
我正在编写一个表示矩阵的类,遇到了一个错误:倒数第二行的"<"标记之前的"预期')'"。
template<typename T>
class Matrix;
template<typename T>
Matrix<T> operator-(const Matrix<T> &self);
template<typename T>
ostream & operator<<(ostream &out, const Matrix<T> &matrix);
template<typename T> class Matrix
{
public:
friend ostream & (operator<<<> )(ostream &out, const Matrix &matrix);
friend Matrix (operator-<>)(const Matrix &self); //error here
};
一定是使用 Linux GCC 的 eclipse 的一个错误。通过使用不同的编译器进行编译来解决它。
相关文章:
- C++模板来检查友元函数的存在
- 如何使用单独文件中的派生类访问友元函数对象
- 模板化的类和友元函数
- 友元函数无法访问私有数据成员 (c++)
- 继承和友元函数,从基类访问受保护的成员
- 如何在友元函数中使用静态成员而不添加前缀 [类名]::
- 在模板类之外定义友元函数的正确方法是什么?
- 2个模板化类的非模板友元函数未定义引用错误
- C++ 友元函数和私有构造函数
- 使第二个类的构造函数成为第一个类中的友元函数
- 未定义的类模板不会实例化以检查友元函数
- C++类中的友元函数有问题?
- 使用typedef'ed返回类型声明友元函数时出现编译器错误
- 模板类中的模板友元函数
- C++ 17 个友元函数声明和内联命名空间
- 友元函数需要一个帮助程序函数
- 在类内定义的友元函数与类外定义的友元函数的查找规则之间的差异
- 运算符重载在 C++ 中使用友元函数
- 类C++友元函数无法访问封装的类
- 函数指针作为友元函数