please help me i cant seem to fix this program. i have 3 syntax errors and i dont know how to fix them. can someone show me how to do it plz?
Code:
#include <stdafx.h>
#include <iostream>
using namespace std;
class TwoD
{
private:
int rows;
int cols;
typedef int* IntArrayPtr;
public :
TwoD( );
TwoD(int MaxRows, int MaxCols);
void setValue(int row, int col, double value);
double getValue(int row, int col);
int getMaxRow();
int getMaxCol();
void destructure();
int d1,d2,i,j,m[20][20];
};
TwoD::TwoD()
{
rows = 5;
cols = 6;
IntArrayPtr *m = new IntArrayPtr[rows];
for (int i = 0; i,rows; i++)
{
m[i] = new int[cols];
}
}
TwoD::TwoD(int maxRows,int maxCols)
{
rows = maxRows;
cols=maxCols;
IntArrayPtr *m = new IntArrayPtr[rows];
for (int i= 0; i<rows; i++)
{
m[i]= new int[cols];
}
}
void TwoD::setValue(int row, int col, double value)
{
m[row][col] = value;
}
double TwoD::getValue(int row, int col)
{
return m[row][col];
}
int TwoD::getMaxRow()
{
return rows;
}
int TwoD::getMaxCol()
{
return cols;
}
void TwoD::destructure ()
{
for (int i=0; i<d1; i++)
{
delete []m [i];
delete []m;
}
}
const TwoD TwoD::operator + (const TwoD&m, const TwoD&n) conts; // error C2039: '+' : is not a member of 'TwoD' - error C3646: 'conts' : unknown override specifier - error C2447: '{' : missing function header (old-style formal list?)
{
int mRows=m.getMaxRows();
int nRows=n.getMaxRows();
int mCols=n.getMaxCols();
int nCols=n.getMaxCols();
if(mRows!=nRow||mCols!=nCols)
{
cout<< "Dimensions Not Equal :\n";
return null:
}
TwoD sum(mRows,mCols)
for(int i=0; i<mRows; i++)
{
for (int j=0; j<mCols; j++)
{
double mValue = getvalue(mRow,mCol);
double nValue = getvalue(nRow,nCol);
double mAndN = mValue + nValue;
sum.setValue(mRows, mCols,mAndN);
}
return sum;
}
}
int main ()
{
int d1,d2,i,j,value;
cout << "Enter the row and column dimensions of the array:\n";
cin >> d1 >> d2;
TwoD matrix (d1,d2);
cout << "Enter" <<d1<<"rows of" <<d2<< "integers each: \n";
for (i=0; i<d1; i++)
for (j=0; j<d2; j++)
double value;
cin>>value;
matrix.setValue (d1, d2, value);
cout<<"Echoing the two-dimensional array: \n";
for (i=0; i<d1; i++)
{
for (j=0; j<d2; j++)
cout<<matrix.getValue(d1,d2);
}
return 0;
}
thanks again and i also added where the errors are