栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

求助:C++模板类友元函数重载运算符时出现的问题

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

求助:C++模板类友元函数重载运算符时出现的问题

        最近在编写矩阵模板类的时候出现了这样的问题:

        这是报错信息: 这是源代码:

// Math_mTool_classTemplate.hpp用于定义类模板

# include

# include

using namespace std;

#ifndef _MATH_MTOOL_CLASSTEMPLATE_HPP

#define _MATH_MTOOL_CLASSTEMPLATE_HPP

template

class Matrix{

private:

    Numtype*** array_row;   // 二维数组,该数组保存 数据对象的指针

    int row;    // 该矩阵的行数

    int col;    // 该矩阵的列数

public:

    Matrix():array_row(NULL),row(0),col(0){};   // 无参数构造函数

    Matrix(Numtype*** a,int r,int c);   // 构造函数

    Matrix(int r,int c);    // 构造函数重载,创建 r*c 的矩阵(空的)

    ~Matrix();  // 析构函数申明

    void pLTFir(int r1,int r2); // 第一类初等行变换(成员函数)

   

    void pLTSec(int r,const Numtype& value);    // 第二类初等行变化重载

    void pLTThi(int r1,int r2,const Numtype& value);    // 第三类初等行变换的函数重载

    friend Matrix operator+<>(Matrix& m1,Matrix& m2);    // 接收两个运算算子的引用,返回一个Matrix对象

    friend Matrix operator-<>(Matrix& m1,Matrix& m2);    //

   

    friend Matrix operator * <> ( Matrix& m1, Matrix& m2);  // 乘法重载

    friend Matrix operator * <>(Numtype& f,Matrix& m2);

    friend Matrix operator*(Matrix& m1,Numtype& f);

    friend Matrix operator*(int value,Matrix& m2);

    friend Matrix operator*(Matrix& m1,int value);

   

    friend istream& operator>> <>(istream& input,Matrix& m);   // 对流插入运算符的重定义

    friend ostream& operator<< <>(ostream& output,const Matrix& m);// 对流提取运算符的重定义

    // 注意插入和提取运算符返回值必须返回引用

};

#endif

希望大佬能帮忙指出错误,感谢!!

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/935838.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号