main.cpp
# include<iostream>
# include"Square_Matrix.h"
using namespace std;
int main()
{
Square_Matrix a;
a.Set_Size(3);
a.Set_Elem(9,2,2);
return 0;
}
Square_Matrix.h
# ifndef SQUARE_MATRIX_H
# define SQUARE_MATRIX_H
# include <iostream>
using namespace std;
class Square_Matrix
{
private:
int new_size = 0;
int new_value = 0;
int num_row = 0;
int num_column = 0;
int **matrix;
public:
Square_Matrix();
void Set_Size(const int new_size); // user set size of array
int Get_Size() const; // back work // creat array
void Set_Elem(const int new_value, int num_row, int num_column); //user use // give num for target space
int Get_Elem(int num_row, int num_column) const; // back work // set target space in array
void operator= (Square_Matrix rh);
~Square_Matrix();
};
# endif /* SQUARE_MATRIX_H */
Square_Matrix.cpp
# include "Square_Matrix.h"
# include <iostream>
using namespace std;
Square_Matrix::Square_Matrix()
{
*matrix = new int [new_size];
};
void Square_Matrix::Set_Size(const int new_size)
{
this -> new_size = new_size;
};
int Square_Matrix::Get_Size() const
{
return matrix[new_size][new_size];
};
void Square_Matrix::Set_Elem(const int new_value, int num_row, int num_column)
{
matrix[num_row][num_column] = new_value;
cout << matrix [num_row][num_column] << endl;
};
int Square_Matrix::Get_Elem(int num_row, int num_column) const
{
return num_row, num_column;
};
Square_Matrix::~Square_Matrix()
{
delete [] *matrix;
}