求高手,编写一个程序实现一个矩阵类,通过重载+,-,*运算符来实现矩阵的加,减,乘操作。

来源:百度知道 编辑:UC知道 时间:2024/07/07 23:46:18
最好用C++实现,谢谢大家啊。。
稍微有点问题,编译通不过啊,请帮忙下。

// ---------------- ---------------------
// ----------------------------------------------------------------
// 假期无聊,实现的矩阵类,模板哦!哈哈。。。
/// ------------- ---------------
/// ---------------------------------------------------

#include <iostream>
#include <vector>
#include <cassert>

using namespace std;

template < class T >
class CMatrix
{
public: //------------------ 构造部 -------------------------
CMatrix( void );
CMatrix( unsigned h, unsigned w );
CMatrix( const CMatrix& m );
CMatrix( const vector<T>& vec );
CMatrix( const vector<T>& vec,unsigned h,unsigned w );
~CMatrix(void);
private: //------------------- 数据部 ---------------------------
vector<T> m_vec_data;
unsigned m_u_width;
unsigned m_u_height;

public: // ------------------- 重载运算符 -------------------------