M
Marcin Kalicinski
Hi all,
What is the best practice with redefining operators for a class:
namespace Math
{
class Matrix
{
// ...
bool operator ==(const Matrix &) const; // (1)
}
bool operator ==(const Matrix &, const Matrix &); // (2)
}
Should (1) or (2) be preferred? All data members of Matrix are public, so
there's no problem of access.
In my program I have more "concrete" mathematical classes like Matrix, and I
want to define operators like ==, +, - etc. consistently for all of them.
Which way should I do it best?
Marcin
What is the best practice with redefining operators for a class:
namespace Math
{
class Matrix
{
// ...
bool operator ==(const Matrix &) const; // (1)
}
bool operator ==(const Matrix &, const Matrix &); // (2)
}
Should (1) or (2) be preferred? All data members of Matrix are public, so
there's no problem of access.
In my program I have more "concrete" mathematical classes like Matrix, and I
want to define operators like ==, +, - etc. consistently for all of them.
Which way should I do it best?
Marcin