Hi. I have a do-while inside a switch. Before that I had the definition of a class. So, the thing is that I need to instance objects in the loop with the parameters that the user enter. (EX: c1 with x=3,5 and y=3,6; c2 with x=numberthatuserenter y =numberthatuserenter, etc until the user enter that he don't want to créate any more)
So I Really don't know how to créate this objects with contiguos name (c1,c2,...)
Thanks a lot and sorry for my bad english.
1 2 3 4 5 6 7 8 9 10 11
//...
case 1:
int i = 0;
do {
/* créate instances like c1, c2, c3,... here */
} while (//...);
break;
//...
Yes maybe I can use an array. I didn't think on that. The goal is to "keep" (only in memory for now) some points of a coordinate axis that the users entered.
Then I want to compare everyone of these "objects" (the x parameters and the y parameters of each one) to know the distance, but this is another subject that i will think how to do in a future.
So, with this new information, do you think that I can use an array?
I made Point2D a struct, with the idea that PointData would be a private member of a class.
Otherwise, you could make Point2D a full blown class.
Also, avoid putting too much code into a case: unless it's a one-liner, call a function instead. This helps with readability and aids understanding because it is a form of abstraction.