0% found this document useful (0 votes)
28 views

Object Oriented Programming

The document describes a Matrix class that is used to store and manipulate matrices of integers. It provides the class declaration for Matrix including private data members to store the matrix and public member functions for the constructor, destructor, input, output, setting and getting values, and checking properties of the matrix like if it is identity, rectangular, diagonal, null, triangular, symmetric. The task is to implement all the member functions of this Matrix class with proper error handling.

Uploaded by

sheraz mehmood
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Object Oriented Programming

The document describes a Matrix class that is used to store and manipulate matrices of integers. It provides the class declaration for Matrix including private data members to store the matrix and public member functions for the constructor, destructor, input, output, setting and getting values, and checking properties of the matrix like if it is identity, rectangular, diagonal, null, triangular, symmetric. The task is to implement all the member functions of this Matrix class with proper error handling.

Uploaded by

sheraz mehmood
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Object Oriented Programming

You are required to implement a class Matrix whose objects should be able to store a matrix of integers.
This class must provide the implementation of all the member functions whose declaration is given in the
Matrix class. Feel free to include any additional methods that can help you to fulfill this task. Proper error
handling and checking must be applied wherever required in the implementation.

class Matrix
{
private:
//A two dimensional array of integers dynamically allocated based on
//rows and cols
int **data;
int row; //number of rows in matrix
int col; //number of columns matrix

public:

//Default constructor creates 3*3 matrix and initialize it with zero


Matrix ();

//Parameterized constructor, create row*col matrix and initialize it


//with zero.
Matrix (int row, int col);

//Destructor: Free any memory resources occupied by an object.


~Matrix ();

/*It should take input of a Matrix and during input user also must know
at which indexes input is being taken*/
void input ();

//It should display matrix in grid view


void output () const;

//For setting some value (val) at a particular location of matrix


void setAt (int val, int row, int col);

//For getting some value at a particular location of matrix


int getAt (int row, int col) const;

//return true if the matrix is an identity matrix; false otherwise


//If aij = 0 for i != j and aij = 1 for all i = j is identity matrix
bool isIdentity () const;

//In which number of rows are not equal to number of columns.


bool isRectangular () const;

//Return true if the matrix is a diagonal matrix; false otherwise


//If aij = 0 for all i != j and at least one a ij != 0 for i = j; is
//diagonal matrix
bool isDiagonal () const;

//Return true if the matrix is a null matrix; false otherwise


//A matrix whose each element is zero is null matrix
bool isNullMatrix () const;
//Return true if the matrix is a Triangular matrix; false otherwise
//A matrix that is either Lower-Triangular or Upper-Triangular
bool isTriangular () const;

//Return true if *this and c2 are equal otherwise false.


bool isSymmetric ();
//Take the transpose of the matrix.

void Transpose ();


//Add *this (calling object) and c2 and return the result in a
//new Matrix object.

};

You might also like