I have a class CS which is to represent the co-ordinate system in 3D i.e.(x, y, z)
class CS
{
private:
double x;
double y;
double z
You can't change the positions of x,y,and z to be NULL, since there positions will always be offsets from the CS object. They will always exist. It's not that CS
has an x
like you have a car, it's like CS
has an x
like you have a head. You can't not have a head. If they were integers, you would have to make them pointers (like you said you didn't want to do), because that would be the only way to tell uninitialized from initialized. However, double
s have a magic value that is rarely used:
CS:CS()
: x(std::numeric_limits::quiet_NaN())
: y(std::numeric_limits::quiet_NaN())
: z(std::numeric_limits::quiet_NaN())
{ }
Users probably won't be setting x, y, and z to (NOT A NUMBER) intentially.