Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
0Activity
0 of .
Results for:
No results containing your search query
P. 1
Opp

Opp

Ratings: (0)|Views: 39|Likes:
Published by Xuan Phong

More info:

Published by: Xuan Phong on May 23, 2013
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOCX, PDF, TXT or read online from Scribd
See more
See less

05/23/2013

pdf

text

original

 
Bài ma tr
n
Matric.h
#include<iostream>using namespace std;template <typename T>class Matrix{int m,n;//m la so hang,n la so cotT **data; public:Matrix(int = 3,int = 3);~Matrix();Matrix(const Matrix<T>&);Matrix<T> operator =(const Matrix<T>&);Matrix<T> operator +(const Matrix<T>&);Matrix<T> operator -(const Matrix<T>&);Matrix<T> operator *(const Matrix<T>&);T &operator ()(int,int)const;template <typename K>friend ostream &operator <<(ostream& ,const Matrix<K>& );template <typename K>friend istream &operator >>(istream& ,Matrix<K>& );};//-----------------------------------------------------------------template <typename T>Matrix<T>::Matrix(int m,int n):m(m),n(n){assert(m>0&&n>0);
 
data = new T*[m];//assert(data!=0);for(int i=0;i<m;i++){data[i] = new T[n];//assert(data[i]!=0);}}//-----------------------------------------------------------------template <typename T>Matrix<T>::~Matrix(){for(int i=0;i<m;i++) delete []data[i];delete []data;}//-----------------------------------------------------------------template <typename T>Matrix<T>::Matrix(const Matrix<T>& obj){m=obj.m;n=obj.n;data=new T*[m];//assert(data!=0);for(int i=0;i<m;i++){data[i]=new T[n];//assert(data[i]!=0);}for(int i=0;i<m;i++)
 
for(int j=0;j<n;j++) data[i][j]=obj(i,j);}//------------------------------------------------------------------template <typename T>Matrix<T> Matrix<T>::operator =(const Matrix<T>& obj){if(this!=&obj){for(int i=0;i<m;i++) delete []data[i];delete []data;m=obj.m;n=obj.n;data = new T*[m];//assert(data!=0);for(int i=0;i<m;i++){data[i]=new T[n];//assert(data[i]!=0);}for(int i=0;i<m;i++)for(int j=0;j<n;j++) data[i][j]=obj(i,j);}return *this;}//-------------------------------------------------------------------template <typename T>T &Matrix<T>::operator ()(int i,int j)const{if(i>=0 && i<m && j>=0 && j<n);

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->