c++中矩阵相乘(对象数组与对象指针的应用)

c++中矩阵相乘(对象数组与对象指针的应用)

  1. 设计一个矩阵类 Matrix(矩阵由二维数组实现),有分配空间和对矩阵赋值的功能。
  2. 将这个矩阵类的对象作为参数传送到函数 Mul()
  3. 用三种方式传递参数:
    直接传送:Mul(Matrix a,Matrix b),实际上只是传送值,在函数中针对 对象的任何修改均不影响该对象本身
    指针传送:Mul(Matrix *pa,Matrix *pb)
    引用传送:Mul(Matrix &a,Matrix &b)

  4. 将 Mul() 函数实现

  5. 定义一个友元函数实现转制功能。转制是指将数组中 a[i][j]与 a[j][i]的值对调。
    下面给出代码
#include<iostream>   
using namespace std;

class Matrix  {   //定义类
private:       
    int **pmatrix;       
    int imaxx,imaxy;       
    static int matrixnum;  //计算有多少个矩阵 
public:       
    Matrix(unsigned int x,unsigned int y);       
    Matrix(Matrix &m);       
    ~Matrix();       
    void SetValue(unsigned int x,unsigned int y,int value);       
    void input();       
    void print() const;       
    friend Matrix Rotate(Matrix &m);  //定义友元函数实现转置功能     
    friend Matrix Mul(Matrix a,Matrix b); //定义MUL函数,实现矩阵相乘的功能
    unsigned int getx(){
  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值