"<<" operator overloading
Code:
#include <iostream>
#include <cstring>
using namespace std;
class Matrix{
private:
int i,j;
public:
int mat[5][5];
Matrix(int x,int y,int p){
for(i=0;i<x;i++)for(j=0;j<y;j++)mat[i][j]=p;
}
};
int main(){
Matrix m(5,5,1);
cout << m(2,2) << endl;
return 0;
}
Hello all ... i want to show the element of mat[2][2] using cout (<<) operator overloading.How can i do this ??
Thanks in advance :)
Re : "<<" operator overloading
Hi,
As I understand your question you don't need any operater overloading. Just use a method to get mat[i][j] value. you can pass the i & j as parameters.
Shanuka