I have a 2D figure made from straight lines.
The figure’s edges have coordinates from type double. The coordinates’ values are stored in an object called Dot.
The data related to a line (is the line ascending or descending, the values of “a” and “b” in “a * X + b == Y” etc.) is stored in an object called Line. The Line class also has two Dot objects for the two ends of every line. The Line class also has 2 functions/methods and one constructor. The constructor has no arguments. The first function/method has no arguments and the second one has. Both functions/methods are created in order to change all the data automatically when ever necessary.
I insert the number of the sides of the figure and the coordinates of the edges after I start the program. Later the program has to write on the screen everything about every line. No matter what coordinates I insert, the coordinates of the first dot are X = -9,25596e+061 and Y = -9,25596e+061. But the other dots have the coordinates I have originally inserted.
There is one line that I add to a vector as much times as the number of the sides of the figure. After that I start changing the values of the coordinates of the edges of the figure (by inserting the values in the running program). The third action is to call the function/method that “creates” the lines (It calculates the rest of the data about the line). The fourth step of the program is to write on the screen the data about every line.
I have been searching for a problem in the algorithm and the code. I haven’t found anything.
I’m using Visual C++ 2010 Express. I am also using the iostream and vector libraries.
So why are the X and Y coordinates of the first edge changing their values to -9,25596e+061?
OK, the problem appeared to be in the code. I haven’t been initializing right… Had to swap the places of two variables in order to fix the problem. Thanks to Hans Passant and Baltram I figured where to search for the problem: when calling elements from any type of array.
Yeah, always be careful when doing such things.