Can't get void statement to not give answer from wrong inputs

Hi.
I'm trying to get a calculation in a void statement to
1)recognize wrong inputs,
2) NOT print out an answer and then
3) return to the main menu.
It does 1 and 3 but keeps printing out a bad answer.
any help?
thanks

1
2
3
4
5
6
7
8
9
10
11
12
13
void Matrix::addMatrix(Matrix A, Matrix B, Matrix& C){
	C.matrixCheck(A.rows(),A.cols()) ;
	if(A.rows()!=B.rows() || A.cols()!= B.cols())
	{
		cerr<<"Matrices are incompatible!"<<endl;

	}
	C.row = A.rows();
    	C.col = A.cols();
	for(int rowIndex=0; rowIndex<A.rows(); rowIndex++)
		for(int colIndex=0; colIndex<A.cols(); colIndex++)
			 C.values[rowIndex][colIndex]=A.values[rowIndex][colIndex]+B.values[rowIndex][colIndex];
}
Last edited on
1. Use code tags on the posts.

2. If you want to return from a function, then return.
Topic archived. No new replies allowed.