I have two simple classes for working with 3d geometry Point
and Vector
. They both have 3 coordinates as public member variables and define some operators like +, -, * ...
.
class Point
{
public:
double x, y, z;
// ctor and some operators
}
class Vector
{
public:
double x, y, z;
// ctor and some operators
}
Is there any real argument against making the coordiantes public?
I will never change double
to any other type. I do not want to restrict the values of x, y, z
to a special range and I do not want to check anything when setting the coordinates.
The classes are in a library which will be used by other projects.
Update:
For me a big disadanvtage of setters/getters would be to have to write/read code like this:
myVec.setX(myVec.x() + 1.0);
instead of
myVec.x += 1.0;
Upadate 2:
Qt uses getters/setters in QPoint but with no benefit