gpt4 book ai didi

c++ - 使用模板c++的友元函数语法错误

转载 作者:行者123 更新时间:2023-11-28 06:28:19 26 4
gpt4 key购买 nike

我正在编写一个表示矩阵的类,但遇到了一个错误:倒数第二行的“<”标记之前的“预期的‘)’”。

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++的友元函数语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28138993/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com