help with a little question

How save Coordinate on a array?

I have a program that work with portals, but no is exactly a portal, because first I tell me that a array of 10^9 and so that I occuoy all my memory and that do a Segmentation fault, so that is a array imaginary , because I think that a put 2 coordenates X abd Y and save in a array, this is my code, my teacher tell us that we need work with POO and I don't know good POO and I have that do a Backtacking for do all posible combinations of portals, help me with this please, I thank you

#include <iostream>
using namespace std;

class portal{
private:
int x;
int y;

public:

portal ();
portal (int _x , int _y){ //constructor
x = _x;
y = _y;
}

int getx () { return x ;}
int gety () { return y ;}
};

int main () {

int icant,ix,iy;
portal coor [icant];
cin>>icant;
cin>>ix>>iy;
portal P (ix, iy);
;

if((icant>12) || (icant<2) || (icant%2 !=0))
return 1;
else

for (int i=0;i <= icant;i++){
coor[i];
}


return 0;
}
1
2
int icant,ix,iy;
portal coor [icant];

What do you think the size of the array is?
Hint #1: icant is an uninitialized variable.
Hint #2: C++ does not allow allocating an array from a non-const variable.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
http://v2.cplusplus.com/articles/jEywvCM9/
It makes it easier to read your code and it also makes it easier to respond to your post.
Hint: You can edit your previous post, highlight your code and press the <> formatting button.
ok, the icant is for the number of portal, because the portals are number pair, for that I use the conditional, and my idea was that 2 points X,Y and that save in a array, but that array will be of type portal.
You didn't answer the question.

I didn't ask what icant is. I asked what value does it have?

You can't create an array using an uninitialized variable as the size of the array.
Topic archived. No new replies allowed.