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);
;
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.