I need to print static matrix overloading "<<" operator. Here is my code:
class Matrix
{
public:
int matrix[3][3];
friend std::ostream& operator<<(std::ostream& out, const Matrix& e);
};
std::ostream& operator<<(std::ostream& out, const Matrix& e)
{
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
out << e.matrix[i][j]<<" ";
}
out << std::endl;
}
out << std::endl;
return out;
}
and main function
int main
{
int A[3][3] = { {1,1,1},{1,0,0},{0,0,1} };
}
My problem is I don't know how to use in main function my overloaded operator to print matrix A.