adarshakb
07-15-2009, 05:00 PM
here is the sample of the code not working
#include <iostream.h>
class matrix
{
private:
int maxrow,maxcol;
int *ptr;
public:
matrix(int r,int c)
{
maxrow=r;
maxcol=c;
ptr=new int[r*c];
}
void getmat()
{
int tmp=0;
cout<<"\nEnter a matrix of "<<maxrow<<" row and "<<maxcol<<"col\n";
for(int i=0;i<maxrow;i++);
{
for(int j=0;j<maxcol;j++)
{
tmp=maxcol*i;
cin>>ptr[tmp+j];
}
}
}
////////////still a lot of code deleted......
void main()
{
matrix a(3,3);
matrix b(3,3);
a.getmat();
b.getmat();
a.printmat();
b.printmat();
cout<<"\na=a+b;";
a=a+b;
cout<<"\na=a+b;";
a=a-b;
cout<<"\na=a+b;";
a=a*b;
}
I cant enter the matrix.. ONLY 3 numbers are being accepted
and when i checked in the debuger...i had a surprise:rolleyes:
the value of i was 3 from even when the loop of j was entered 1st time:confused: cant figure out how 0 became 3
#include <iostream.h>
class matrix
{
private:
int maxrow,maxcol;
int *ptr;
public:
matrix(int r,int c)
{
maxrow=r;
maxcol=c;
ptr=new int[r*c];
}
void getmat()
{
int tmp=0;
cout<<"\nEnter a matrix of "<<maxrow<<" row and "<<maxcol<<"col\n";
for(int i=0;i<maxrow;i++);
{
for(int j=0;j<maxcol;j++)
{
tmp=maxcol*i;
cin>>ptr[tmp+j];
}
}
}
////////////still a lot of code deleted......
void main()
{
matrix a(3,3);
matrix b(3,3);
a.getmat();
b.getmat();
a.printmat();
b.printmat();
cout<<"\na=a+b;";
a=a+b;
cout<<"\na=a+b;";
a=a-b;
cout<<"\na=a+b;";
a=a*b;
}
I cant enter the matrix.. ONLY 3 numbers are being accepted
and when i checked in the debuger...i had a surprise:rolleyes:
the value of i was 3 from even when the loop of j was entered 1st time:confused: cant figure out how 0 became 3