i tried to compile my program in C++, but g++ see a lot of errors with operator=, in VS compile without any warning. Please help.
edit. Definition of operator=: Matrix &Matrix::operator=(Matrix &mat){
delete [] tab;
hei = mat.hei;
tab = new Wektor[hei];
for (int i = 0; i < hei; i++){
tab[i] = mat.Tab()[i];
}
return *this;
}
Definition of function with which is problem: void PlusMat(Matrix *lista, int imat){
Matrix add;
if (imat < 2){
cout << "At least 2 matricies!";
return;
}
if ( ((((lista[0]).Tab()[0]).Len()) != (((lista[1]).Tab()[0]).Len())) || (((lista[0]).Hei()) != ((lista[1]).Hei()))){
cout << "Matrices must have the same dimensions!";
return;
}
cout << lista[0];
cout << " + \n";
cout << lista[1];
cout << " = \n";
add = ((lista[0]) + (lista[1]));
// ^ problem
cout << add;
}
edit 2:
I correct this function, but now is another problem:
Wektor &Wektor::operator=(const Wektor &wek) {
delete [] tab;
len = wek.len;
tab = new int[len];
for (int i = 0; i < len; i++)
tab[i] = wek.Tab()[i];
// ^ ^
return *this;
}
the object has type qualifiers that are not compatible with the member function object type is: const Wektor btw i'm sorry, but this is my first post here.