#include using namespace std; class my_matrix { int matrix[2][2]; public: void set_entries (); int trace () ; int determinant(); }; void my_matrix::set_entries () { //declaring the entries of the 2 dimensional array. for (int i = 0 ; i < 2 ; ++i ) for (int j = 0 ; j < 2 ;++j) matrix[i][j] = i+j ; } int my_matrix::trace() { int return_value = 0 ; for (int i = 0 ; i < 2 ; ++ i) return_value +=matrix[i][i] ; return return_value ; } int main () { my_matrix mat ; mat.set_entries (); cout << "trace of the matrix " << mat.trace() << endl; return 0; }