1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#include "2x2.h"
using namespace std;
#include <iostream>
M22::M22(int e=1,int f=0,int g=1,int h=0):a(e),b(f),c(g),d(h) {}
M22::M22():a(1),b(0),c(0),d(1){}
M22::TmpM22 operator [](int lhs){
return TmpM22(lhs,this->a,this->b,this->c,this->d,0);
}
ostream & operator << (ostream &lhs, M22 const & rhs){
return lhs << '[' << rhs.a << ',' << rhs.b << ']' << ',' << '[' << rhs.c << ',' << rhs.d << ']';
}
//TmpM22
M22::TmpM22::TmpM22(int _lhs,int _aVal,int _bVal,int _cVal,int _dVal,int matrix){
lhs=_lhs;
_a=_aVal;
_b=_bVal;
_c=_cVal;
_d=_dVal;
matrixVal=matrix;
}
int M22::TmpM22::operator [](int rhs){
if(lhs==1 && rhs==1){
matrixVal= _a;
}else if(lhs==1 && rhs==2){
matrixVal= _b;
}else if(lhs==2 && rhs==1){
matrixVal=_c;
}else{
matrixVal=_d;
}
return matrixVal;
}
|