I am working with a project in VC++ which involves co-ordinate system having x,y,z axis.I am trying to check for if a variable(Point with x,y,z values) is assigned on the coordinate system or its a default point(uninitialized) .Since a coordinate system I cannot assign a default value to the variable to be either negative or positive  or even zero since all these are valid values.  My approach over here is to have a Boolean variable associated with my Point variable. If the Boolean is set then Point assigned else not. Now I have to check for each and every statement where the value can be assigned and set the Boolean. Now I tried with this approach which is pretty bad and you may consider it as wrong. What I am doing here is taking an uninitialized float variable (since x,y,z members of Point are float) and comparing it with x,y,z members of Point variable.Since in the case where Point is uninitialized both float variable and members of Point match and I can declare its uninitialized. I have tried to test this on different compilers and I get the result as expected.Obvious I get a compiler warning for uninitialized variable used for comparison My question, Is the second approach really bad or is there any workarounds over this.   
variable comparison without initialising
c++;programming practices;variables;initialization
Why not use boost::optional or similar functionality?boost::optional<point> point;if(point)    //is init.You could make your own template class, but having a separate bool flag is not very good, since it clutters the namespace in every place you want a 'nullable' point. It is also not semantically obvious that the point and the bool are grouped/belong together - especially if multiple people view the code at different points in development etc.Putting it in the point class is not 100% semantically correct imo - its better to use composition to represent this kind of thing, since a point is a point. If you layer it with a templated 'holder' that groups the bool together with the it is obvious what happens - and other places where you simply need a point, you use the Point as-is.