Question: lin_0912.h: the matrix class #ifndef MATRIX_H #define MATRIX_H #include #include #include #include #include /** * A generic 2-dimensional array class * @author Jon Beck *

 lin_0912.h: the matrix class 
 #ifndef MATRIX_H #define MATRIX_H #include  #include  #include  #include  #include  /** * A generic 2-dimensional array class * @author Jon Beck * @version 8 September 2017 */ template  class Matrix { public: /** * Constructor, specifying number of both rows and columns * @param rows the number of rows * @param cols the number of columns */ Matrix( uint16_t rows, uint16_t cols ); /** * Access to an element to allow modification * @param row the row index * @param col the column index * @return reference to the element at that position */ Object & at( uint16_t row, uint16_t col ); /** * Constant access to an element * @param row the row index * @param col the column index * @return constant reference to the element at that position */ const Object & at( uint16_t row, uint16_t col ) const; /** * Destructor to free allocated memory */ ~Matrix(); /** * Copy constructor to make 1-1 copy of existing matrix * @param m the existing matrix to be copied */ Matrix( const Matrix & m ); // Copy constructor /** * Disallow the rvalue copy constructor */ Matrix( const Matrix && m ) = delete; /** * Assignment operator to make 1-1 copy of existing matrix * @param m the existing matrix to be copied */ Matrix & operator= ( const Matrix & m ); // Assignment operator /** * Disallow the rvalue assignment operator */ Matrix & operator= ( const Matrix && m ) = delete; /** * Accessor to determine how many rows are in the matrix * @return the number of rows in the matrix */ uint16_t numrows() const; /** * Accessor to determine how many columns are in the matrix * @return the number of columns in the matrix */ uint16_t numcols() const; private: uint16_t rows; uint16_t cols; Object* data; }; template  Matrix::Matrix( uint16_t rows, uint16_t cols ) : rows( rows ), cols( cols ) { data = new Object[ rows * cols ]; } template  Matrix::~Matrix() { delete[] data; } template  Object & Matrix::at( uint16_t row, uint16_t col ) { assert( row < rows && col < cols ); return data[ cols * row + col ]; } template  const Object & Matrix::at( uint16_t row, uint16_t col ) const { assert( row < rows && col < cols ); return data[ cols * row + col ]; } template  uint16_t Matrix::numrows() const { return rows; } template  uint16_t Matrix::numcols() const { return cols; } bool is_connected(Matrix & graph) { vector< bool >reached(graph.size(),false); queue< uint8_t > to_be_explored; to_be_explored.push(0); while(!to_be_explored.empty()) { uint8_t current_node=to_be_explored.front(); to_be_explored.pop(); reached.at(current_node)=true; for(uint8_t adjacent=0; adjacent                                            
                    

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!