我的C++代码示例中存在一个大问题."朋友"和"模板"有问题.
错误消息:
Matrix.h:26:79:警告:
friend声明'std :: ostream&matrixClass :: operator <<(std :: ostream&,const matrixClass :: Matrix&)'声明一个非模板函数[-Wnon-template-friend] friend std :: ostream&operator <<(std :: ostream&,const Matrix&matrix);
Matrix.h:26:79:注意:
Run Code Online (Sandbox Code Playgroud)(if this is not what you intended, make sure the function template已声明并在此处添加<>后的函数名称)
Matrix.h:28:77:警告:
Run Code Online (Sandbox Code Playgroud)friend declaration 'matrixClass::Matrix<T>*matrixClass :: operator*(const matrixClass :: Matrix&,const matrixClass :: Matrix&)'声明一个非模板函数[-Wnon-template-friend]朋友Matrix*operator*(const Matrix&m1,const Matrix&m2);
Matrix.cpp:1:0:
C:\ Users\Peter\CLIONProjects\PK\untitled76\Matrix.h:26:79:警告:朋友声明'std :: ostream&matrixClass :: operator <<(std :: ostream&,const matrixClass :: Matrix&)'声明非模板函数[-Wnon-template-friend]朋友std :: ostream&operator <<(std :: ostream&,const Matrix&matrix);
Matrix.h:26:79:注意:
Run Code Online (Sandbox Code Playgroud)(if this is not what you intended, make sure …