模版实现矩阵综合运算

上传人:第*** 文档编号:38886079 上传时间:2018-05-09 格式:DOC 页数:5 大小:55.50KB
返回 下载 相关 举报
模版实现矩阵综合运算_第1页
第1页 / 共5页
模版实现矩阵综合运算_第2页
第2页 / 共5页
模版实现矩阵综合运算_第3页
第3页 / 共5页
模版实现矩阵综合运算_第4页
第4页 / 共5页
模版实现矩阵综合运算_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

《模版实现矩阵综合运算》由会员分享,可在线阅读,更多相关《模版实现矩阵综合运算(5页珍藏版)》请在金锄头文库上搜索。

1、 模版实现矩阵综合运算1程序代码#include #include #include #include using namespace std; namespace NameVector #define DEFAULT_ALLOC 2 templateclass matrix; template class vector private: friend class matrix; EIType * data; int len; public: int length()constreturn len; vector(); vector(int n); vector()delete data; v

2、ector(const vector vector EIType void zero(); vectoroperator+(const vector friend ostream friend istream ; template void vector:zero() for(int i=0;iEIType assert(data!=0);len=DEFAULT_ALLOC; template vector:vector(int n) data=new EITypelen=n; assert(data!=0); template vector:vector(const vector asser

3、t(data!=0); for(int i=0;i vector data=new EITypelen=original.len; assert(data!=0); for(int i=0;i vectorvector:operator+(const vector for(int i=0;i ostream return is; template class matrix vector *m; int rows,cols; public: matrix(); matrix(int r,int c); matrix(const matrix matrix()deletem; matrix vec

4、tor matrixoperator+(const matrix friend ostream friend istream ; template matrix:matrix() m=new vectorDEFAULT_ALLOC; assert(m!=0); rows=cols=DEFAULT_ALLOC; for(int i=0;iv; mi=v; template matrix:matrix(int r,int c) m=new vectorv(cols); mi=v; template matrix:matrix(const matrix rows=s.rows; m=new vect

5、orrows; assert(m!=0); cols=s.cols; for(i=0;i matrix rows=s.rows; cols=s.cols; m=new vectorrows; assert(m!=0); for(int i=0;i vector assert(rows=a.rows); assert(cols=a.cols); matrixans(a.rows,a.cols); for(i=0;i ostreami istream return is; using namespace NameVector; int main() vectorvec1(1),vec2(2),vec3; cinvec1;cinvec2; vec3=vec1+vec2; coutvec3; return 0; 2结果截图

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 其它办公文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号