What is the best way to indicate that a double value has not been initialized?

前端 未结 9 1918
萌比男神i
萌比男神i 2020-12-22 06:26

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         


        
9条回答
  •  时光取名叫无心
    2020-12-22 06:53

    If I understand correctly, you want to be able to tell the difference between an invalid, default constructed CS and a valid one with values (0.0, 0.0, 0.0). This is exactly what boost::optional http://www.boost.org/doc/libs/1_47_0/libs/optional/doc/html/index.html is for.

提交回复
热议问题