#include<iostream.h>
#include<conio.h>
class matrix
{
int r,c,**m,i,j;
public:
matrix(int a=0,int b=0)
{
r=a;
c=b;
m=new int *[r];
for(i=0;i<r;i++)
{
m[i]=new int [c];
}
}
void assgn()
{
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
cout<<"\nEnter value of"<<i+1<<","<<j+1<<": ";
cin>>m[i][j];
}
}
}
void display()
{
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
cout<<m[i][j]<<"\t";
}
cout<<"\n";
}
}
matrix operator ++()
{
matrix t(r,c);
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
t.m[i][j]=++m[i][j];
m[i][j]++;
}
}
return t;
}
};
void main()
{
matrix m1(3,3),m2;
clrscr();
m1.assgn();
cout<<"\nOrignal Matrix\n";
m1.display();
m2=++m1;
cout<<"\nPre increment\n";
m2.display();
cout<<"\npost Increment\n";
m1.display();
getch();
}
No comments:
Post a Comment