i'm getting an error 'identifier display cannot have type qualifier' near the bold portion. what's wrong???
Code:
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
class matrix
{
private: int a[20][20],m,n;
public:
void getdata();
void display();
matrix operator+(matrix c) ;
};
void matrix::getdata()
{
cout<<"enter size"<<endl;
cin>>m>>n;
cout<<"enter elements"<<endl;
for(int i=0;i<=m;i++)
{for(int j=0;j<=n;j++)
cin>>a[i][j];
}
[B]void matrix::display()
{[/B]
for(int i=0;i<=m;i++)
{
for(int j=0;j<=n;j++)
cout<<a[i][j];
cout<<endl;
}
matrix matrix :: operator+(matrix c)
{
matrix l;
if(m!=c.m||n!=c.n)
{cout<<"sdsd";
exit(0);
}
else
{
l.m=m;
l.n=n;
for(i=0;i<=m;i++)
{for(j=0;j<=n;j++)
l.a[i][j]=a[i][j]+c.a[i][j];
} }
return l;
}
void main()
{
matrix x,y,z;
clrscr();
x.getdata();
y.getdata();
z=x+y;
z.display();
getch();
}
Comment