Hi guys, I haven't coded in C++ in ages. And recently, I'm trying to work on something involving structs. Like this
typedef struct{
int x;
int y;
} Point;
Then in a loop, I'm trying to create new structs and put pointers to them them in a list.
Point* p;
int i, j;
while (condition){
// compute values for i and j with some function...
p = new Point;
p* = {i, j}; //initialize my struct.
list.append(p); //append this pointer to my list.
}
Now, my question is it possible to simplify this? I mean, the pointer variable *p outside of the loop and calling p = new Point inside the loop. Isn't there a better/nicer syntax for this?