Create a class called Matrix having the following data members int rows; int cols; int mat[][]. Write a program to implement the following operations (the ones mentioned in comments) on Matrix. The main() function of the above program is as below: int main() { Matrix m1(3,3); // it will initialize rows and cols m1.getdata(); //accept the data in matrix Matrix m2=m1; //copy one matrix contents into another m2.putdata(); // display the contents of matrix Matrix m3; m3.putdata(); }
#include<iostream>
using namespace std;
class Matrix{
public:
int row,col;
void Test(int k, int l){
int mat[k][l];
for(int i=0;i<k;i++){
for(int j=0;j<l;j++){
printf("Test");
}
cout<<"\n"<<endl;
}
}
};
int main(){
Matrix myMatrix;
myMatrix.Test(3,3);
cout<<"sdsf"<<endl;
return 0;
}
Comments
Leave a comment