I am building an type to be able to manage matrixes so i have searched how to make an [][] operator but no luck so any idea how to do that i just need a way to make double operator this the class am building
#include<iostream>
#include<conio.h>
using namespace std;
class ddouble{
private:
unsigned short int x, y;
public:
ddouble();
ddouble(unsigned short int, unsigned short int);
double **M;
void read();
void print();
};
ddouble::ddouble(unsigned short int m, unsigned short int n){
for (int i = 0; i < m; i++){
M = new (nothrow) double *[i];
for (int I = 0; I < n; I++){
M[i] = new (nothrow) double[I];
}
}
}
void ddouble::read(){
for (int i = 0; i < x; i++){
cout << "plz enter line \n";
for (int I = 0; I < y; I++){
cin >> M[i][I];
}
}
}
void ddouble::print(){
cout << "i,j\t|\t";
for (int i = 0; i < y; i++){
cout << i << "\t";
}
cout << endl;
for (int i = 0; i < x; i++){
cout << i << "\t|\t";
for (int I = 0; I < y; I++){
cout << M[i][I] << "\t";
}
cout << endl;
}
}
void main(){
ddouble a(2, 2);
a.read();
a.print();
_getch();
}