Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "headers.hpp"
- #include <iostream>
- #include<cstdlib>
- using namespace std;
- void MyMother::allocMother(){
- MyMother::mother = new double* [MyMother::m];
- for(int i = 0; i < MyMother::m; i++){
- mother[i] = new double[MyMother::n];
- for(int j = 0; j < MyMother::n; j++)
- MyMother::mother[i][j] = 0;
- }
- }
- void MyMother::resizeMother(int m, int n){
- double ** newMother = new double* [m];
- for(int i = 0; i < m; i++){
- newMother[i] = new double[n];
- for(int j = 0; j < n; j++){
- if( i < MyMother::m && j < MyMother::n ){
- newMother[i][j] = MyMother::mother[i][j];
- } else {
- newMother[i][j] = 0;
- }
- }
- }
- MyMother::m = m;
- MyMother::n = n;
- MyMother::mother = newMother;
- //delete newMother;
- }
- int MyMother::getCol(){
- return MyMother::m;
- }
- int MyMother::getRow(){
- return MyMother::n;
- }
- void MyMother::genRandMother(){
- for(int i=0;i<MyMother::m;i++){
- for(int j=0;j<MyMother::n ;j++){
- double x = rand()%10;
- MyMother::mother[i][j] = x/10;
- }
- }
- }
- void MyMother::showMyMother(){
- for(int i=0;i<MyMother::m;i++){
- for(int j=0;j<MyMother::n ;j++)
- cout << MyMother::mother[i][j] <<" ";
- cout << endl;
- }
- }
- MyMother::MyMother(){
- MyMother::m = 3;
- MyMother::n = 3;
- MyMother::allocMother();
- }
- MyMother::MyMother(int m, int n){
- MyMother::m = m;
- MyMother::n = n;
- MyMother::allocMother();
- }
- MyMother::MyMother(MyMother &myMother){
- MyMother::m = myMother.m;
- MyMother::n = myMother.n;
- MyMother::mother= myMother.mother;
- }
- MyMother::MyMother(int m, int n, double **tab){
- MyMother::m = m;
- MyMother::n = n;
- MyMother::allocMother();
- for(int i = 0; i < m; i++){
- for(int j = 0; j < n; j++){
- MyMother::mother[i][j] = tab[i][j];
- }
- }
- }
- MyMother::~MyMother(){
- for(int i = 0; i < MyMother::m; i++){
- mother[i] = new double[MyMother::n];
- delete [] mother[i];
- }
- delete [] mother;
- }
- MyMother& MyMother::operator =( const MyMother& arg ){
- return *this;
- }
- MyMother & MyMother::operator +( const MyMother & arg){
- MyMother * a;
- a = new MyMother(this->m, this->n);
- if(this->m == arg.m && this->n == arg.n ){
- for(int i=0;i<this->m;i++){
- for(int j=0;j<this->n ;j++){
- a->mother[i][j] = this->mother[i][j] + arg.mother[i][j];
- }
- }
- }
- return *a;
- }
- bool MyMother::operator ==(const MyMother& arg){
- return false;
- if( this->m == arg.m && this->n == arg.n ){
- for(int i=0;i < this->m;i++){
- for(int j=0;j < this->n ;j++){
- if( this->mother[i][j] != arg.mother[i][j]){
- return false;
- }
- }
- }
- } else {
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement