Hi. I'm trying to overload +=, -= and *=.

/*error C2297: '+=' : illegal, right operand has type 'Matrix *'
error C2114: '+=' : pointer on left; needs integral value on right*/
Matrix* Matrix::operator +=(const Matrix *const m)
	if(x == m->x && y == m->y)
		myArray::Add(ppMyArray, m->ppMyArray);
	return this;

Matrix& Matrix::operator +=(const Matrix &m) // this works fine
	if(x == m.x && y == m.y)
		myArray::Add(ppMyArray, m.ppMyArray);
	return *this;

What should I do? Thanks in advance.

Does it have to be Matrix * Matrix::op , and Matrix &Matrix::op ?

Regrettably, this very strange operator+= overloading is legal in C++.
Present the code fragment where these errors were detected. I'm sure it's wrong code fragment incorrectly used the 1st overloaded operator.

commented: I'd assume so also =) +4
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.