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.