Combine String2Matrix() with the CMatrix Class

Up to now, we keep assuming that the matrix size is limited to 3x3. This is certainly unsatisfactory. With the String2Matrix() and MeasureMatrixSize(), we can now combine them with the CMatrix class you developed to allow your program flexibly input a matrix with any number of rows and columns.

If your OnBnClickedButton1() look like


void CMultilineView::OnBnClickedButton1()
{
    CString str1, str2, str3;
    
    GetDlgItem(IDC_EDIT1)->GetWindowText(str1);	
    CMatrix a(str1);
    
    GetDlgItem(IDC_EDIT2)->GetWindowText(str2);	
    CMatrix b(str2);
    
    CMatrix c( a.Add(b) );	// c = a + b

    Matrix2String(c, str3);
    GetDlgItem(IDC_EDIT3)->SetWindowText( str3 );
}

you should be able to perform the following matrix addition
ex-matrix_addition4.png