Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have written this code but have 3 errors I can't fix.
Can anyone help me with this?

C++
//this program will find the product of two matrices (2columns X 2rows)...
#include<iostream.h>
class A {
	int x ;
	A(){}
	A(int a){x=a;}
	void out(){cout<<"Enter the value of matrix a:\n";}
};
class B{
	int x;
	B(){}
	B(int a){x=a;}
	void out(){cout<<endl<<"Enter the value of matrix b:\n";}
};
class C{
int x;
	C(){}
	C(int a){x=a;}
	void out(){cout<<"The multiplied value is:\n";}
};


void main() {
int a[4][4],b[4][4],c[4][4];
int i,j,k;
  A a1();
  a1.out();

for(i=0;i<2;i++){

for(j=0;j<2;j++){

cin>>a[i][j];
}
}
B a2();
a2.out();

for(i=0;i<2;i++){

for(j=0;j<2;j++){

cin>>b[i][j];
}
}


C a3();
a3.out();

for(i=0;i<2;i++){

for(j=0;j<2;j++){

c[i][j]=0;
for(k=0;k<2;k++){

c[i][j]=c[i][j]+(a[i][k]*b[k][j]);
}
}
}
for(i=0;i<2;i++){

for(j=0;j<2;j++){

cout<<c[i][j]<<"  ";
}
cout<<"\n";
}
}</iostream.h>
Posted
Updated 19-May-10 7:45am
v3
Comments
Richard MacCutchan 19-May-10 17:07pm    
Please do not post the same question more than once, just edit the original so all your answers are kept together.

1 solution

You forgot to declare class methods (constructor included) as public. For example:
C++
class A {
    int x ;
public:
    A(){}
    A(int a){x=a;}
    void out(){cout<<"Enter the value of matrix a:\n";}
};


The syntax you used for creating class instances is wrong, for instance use
A a1;

instead of
sameer 2010 wrote:
A a1();
 
Share this answer
 
Comments
danger man 2011 19-May-10 15:03pm    
thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900