More details in the PDF file attached.In this assignment you will learn to use operator overloading both as member and non-member
functions, friend functions, this pointer, copy constructor. This assignment is based on matrixoperations like addition, subtraction, multiplication, increment (pre-, post-), decrement (pre-, post-),assignment operation, copy constructor, transpose matrix.
#include "matrix.h" using namespace std; /** * @brief display menu * */ void displayMenu(void) { string stars(34, '*'); cout < endl;="" cout="">< stars="">< endl;="" cout="">< "|="" menu="" |"="">< endl;="" cout="">< "|0.="" quit="" |"="">< endl;="" cout="">< "|1.="" add(+)="" matrix="" |"="">< endl;="" cout="">< "|2.="" sub(-)="" matrix="" |"="">< endl;="" cout="">< "|3.="" mul(*)="" matrix="" |"="">< endl;="" cout="">< "|4.="" (++)pre-increment="" matrix="" |"="">< endl;="" cout="">< "|5.="" post-increment(++)="" matrix="" |"="">< endl;="" cout="">< "|6.="" (--)pre-decrement="" matrix="" |"="">< endl;="" cout="">< "|7.="" post-decrement(--)="" matrix="" |"="">< endl;="" cout="">< "|8.="" assignment(=")" operation="" |"="">< endl;="" cout="">< "|9.="" copy="" constructor="" |"="">< endl;="" cout="">< "|10.="" transpose(!)="" matrix="" |"="">< endl;="" cout="">< stars="">< endl;="" cout="">< "provide="" the="" input="" "="">< endl;="" cout="">< endl;="" }="" **="" *="" @brief="" mail="" function="" *="" *="" @param="" argc="" *="" @param="" argv="" *="" @return="" int="" */="" int="" main(int="" argc,="" char="" **argv)="" {="" ifstream="" input_file;="" ifstream="" input_file2;="" int="" readmatrix1[rows][cols];="" int="" readmatrix2[rows][cols];="" string="" stars(34,="" '*');="" int="" op="100;" int="" size;="" if="" (argc="=" 1)="" {="" cerr="">< "usage:="" ./main="" matrix_1.txt="" matrix_2.txt="" "="">< endl;="" return="" -1;="" }="" else="" if="" (argc=""> 3) { cerr < "error:="" too="" many="" command="" line="" arguments="" "="">< endl;="" return="" -1;="" }="" else="" if="" (argc="=" 3)="" {="" if="" (strcmp(argv[1],="" "matrix_1.txt"))="" {="" cerr="">< "error:="" invalid="" file="" extension="" "="">< endl;="" return="" -1;="" }="" cout="">< "file1="" name=" << argv[1] << endl; if (strcmp(argv[2], " matrix_2.txt"))="" {="" cerr="">< "error:="" invalid="" file="" extension="" "="">< endl;="" return="" -1;="" }="" cout="">< "file2="" name=" << argv[2] << endl; } if (fileOpen(input_file, argv[1]) == -1) { cerr << " \n="" file="" open:="" input="" file"="">< endl;="" return="" -1;="" }="" if="" (fileopen(input_file2,="" argv[2])="=" -1)="" {="" cerr="">< "\n="" file="" open:="" input="" file"="">< endl;="" return="" -1;="" }="" fileread(input_file,="" readmatrix1);="" input_file.close();="" fileread(input_file2,="" readmatrix2);="" input_file2.close();="" while="" (1)="" {="" cout="">< "enter="" squre="" matrix="" size="" min="" :="" 1="" and="" max:="" 10="" "="">< endl;="" cin="">> size; if ((size <= 0)="" ||="" (size=""> 10)) { cout < "error="" :-="" wrong="" size="" "="">< endl;="" cout="">< "please="" provide="" valid="" input="" "="">< endl;="" }="" else="" {="" cout="">< "matrix="" size="" "="">< size="">< "="" x="" "="">< size="">< endl;="" break;="" }="" }="" cout="">< endl;="" matrix="" mat1(size);="" matrix="" mat2(size);="" matrix="" mat3(size);="" print_matrix(readmatrix1,="" rows,="" cols);="" cout="">< "create="" matrix="" 1="" form="" matrix_1.txt"="">< endl;="" mat1.creatematrix(readmatrix1);="" mat1.display();="" print_matrix(readmatrix2,="" rows,="" cols);="" cout="">< "create="" matrix="" 2="" from="" matrix_2.txt"="">< endl;="" mat2.creatematrix(readmatrix2);="" mat2.display();="" while="" (op="" !="0)" {="" displaymenu();="" cin="">> op; switch (op) { case 0: cout < "quit="" "="">< endl;="" break;="" case="" 1:="" cout="">< stars="">< endl;="" cout="">< "addition="" of="" two="" given="" matrices="" is="" :="" "="">< endl;="" mat1="" +="" mat2;="" cout="">< stars="">< endl;="" break;="" case="" 2:="" cout="">< stars="">< endl;="" cout="">< "subtraction="" of="" two="" given="" matrices="" is="" :="" "="">< endl;="" mat1="" -="" mat2;="" cout="">< stars="">< endl;="" break;="" case="" 3:="" cout="">< stars="">< endl;="" cout="">< "multiplication="" of="" two="" given="" matrices="" is="" :="" "="">< endl;="" mat1="" *mat2;="" cout="">< stars="">< endl;="" break;="" case="" 4:="" cout="">< stars="">< endl;="" cout="">< "(++)pre-increment="" of="" matrix1="" :="" "="">< endl;="" ++mat1;="" cout="">< mat1;="" cout="">< "(++)pre-increment="" of="" matrix2="" :="" "="">< endl;="" ++mat2;="" cout="">< mat2;="" cout="">< stars="">< endl;="" break;="" case="" 5:="" cout="">< stars="">< endl;="" cout="">< "post-increment(++)="" of="" matrix1="" :="" "="">< endl;="" mat1++;="" cout="">< mat1;="" cout="">< "post-increment(++)="" of="" matrix2="" :="" "="">< endl;="" mat2++;="" cout="">< mat2;="" cout="">< stars="">< endl;="" break;="" case="" 6:="" cout="">< stars="">< endl;="" cout="">< "(--)pre-decrement="" of="" matrix1="" :="" "="">< endl;="" --mat1;="" cout="">< mat1;="" cout="">< "(--)dec-increment="" of="" matrix2="" :="" "="">< endl;="" --mat2;="" cout="">< mat2;="" cout="">< stars="">< endl;="" break;="" case="" 7:="" cout="">< stars> stars>=>