C++ Matric Calculator Backup
C++ Matric Calculator Backup
#include <iostream>
#include <string>
#include <fstream>
class Matrix {
public:
// default constructor
Matrix() {}
// constructor
Matrix (unsigned int row, unsigned int column): row_count(row),
column_count(column), matrix_pointer(0) {
matrix_struct_pointer = new Matrix_struct(row, column);
matrix_pointer = matrix_struct_pointer->matr;
}
// copy-constructor
Matrix (const Matrix& other): row_count(other.row_count),
column_count(other.column_count), matrix_pointer(0) {
copy(other);
}
// assign-constructor
void operator= (const Matrix& other) {
if (*matrix_pointer != *other.matrix_pointer) {
(*this).~Matrix();
copy(other);
}
}
// destructor
~Matrix () {
delete[] matrix_pointer;
delete this;
}
type next_input;
type next_input;
std::ifstream in;
in.open(filepath);
in.close();
std::cout << "input successful \n";
}
std::ofstream out;
out.open(filepath);
out.close();
std::cout << "Output finished.";
}
if (row > 0 && column > 0 && row <= row_count && column <= column_count)
*(*((matrix_pointer+row)-1) + (column-1)) += value;
else
std::cout << "Row and column have to be positive and within the
dimensions of the matrix. \n";
}
else
std::cout << "Column has to be positive and within the dimensions of
the matrix. \n";
}
else
std::cout << "Row has to be positive and within the dimensions of the
matrix. \n";
}
else
std::cout << "Row and column have to be positive and within the
dimensions of the matrix. \n";
}
else
std::cout << "Column has to be positive and within the dimensions of
the matrix. \n";
}
else
std::cout << "Row has to be positive and within the dimensions of the
matrix. \n";
}
private:
type** matr;
};
int main() {
const int Max_Matrix_Count = 100; // max number of matrices that the programm
can work on at the same time
Matrix* matrices[Max_Matrix_Count];
std::cout << "What are the dimensions of the matrix (row, column)? \n";
std::cin >> row_count;
std::cin >> column_count;
if (row_count = 0) {
std::cout << "Invalid number of rows (has to be > 0).";
std::cin >> row_count;
}
if (column_count == 0) {
std::cout << "Invalid number of columns (has to be > 0).";
std::cin >> column_count;
}
}
std::cout << "How would you like to input your matrix? \n";
std::cout << "For console input, please press 1. \n";
std::cout << "For file input, please press 2. \n";
std::cin >> input_mode;
// console input
if (input_mode == 1) {
if (matrices[slot] == 0) {
// file input
else if (input_mode == 2) {
std::cout << "Please enter the filepath. \n";
std::cin >> filepath;
if (matrices[slot] == 0) {
// matrix-multiplication
// determinant
// output
return 0;
}