Hi,
I am having trouble with accessing dynamic arrays. I need to fill up two arrays in warpImage obj, then use them in another obj by calling getX(index) and getY(index) functions.
What I have is,
Header:
class warpImage {
public:
warpImage(int w, int h);
virtual ~warpImage();
void warp();
int getX(int index);
int getY(int index);
private:
int width, height;
int* X;
int* Y;
}
Source:
warpImage::warpImage(int w, int h)
{
width = w;
height = h;
X = new int[width*height];
Y = new int[width*height];
//have access to X and Y arrays here
}
warpImage::~warpImage()
{
delete [] X;
X = NULL;
delete [] Y;
Y = NULL;
}
warpImage::warp()
{
X and Y arrays should be filled here,
but I cannot access their elements, i.g.
by doing
X[index] = some int;
Y[index] = some int;
debugger got stuck and could not go through.
}
When I called getX() and getY() from another obj, of course it did not work, as the filling up phase was in trouble.
Zaita,
hope you are still up.
I have another class called confidence, which instantiates warpImage. It looks like this
class confidence {
public:
confidence(warpImage& w);
virtual ~confidence();
void computeConfidence();
float triangleArea(int x0, int y0, int x1, int y1, int x2, int y2);
private:
warpImage* wI;
};
confidence::confidence(warpImage& w)
{
wI = &w;
}
confidence::~confidence()
{
}
float confidence::triangleArea(int x0, int y0, int x1, int y1, int x2, int y2)
{
getX() and getY() from warpImage are called here
some calculation
}
void confidence::computeConfidence()
{
some calculation
}
class confidence
{
public:
confidence();
virtual ~confidence();
void computeConfidence();
float triangleArea(int x0, int y0, int x1, int y1, int x2, int y2);
private:
warpImage* wI;
};
confidence::confidence()
{
wl = new warpImage(value_w, value_h);
}
confidence::~confidence()
{}
float confidence::triangleArea(int x0, int y0, int x1, int y1, int x2, int y2)
{
int valueX = wl -> getX(int indexX);
int valueY = wl -> getY(int indexY);
// warning: x0,y0,x1,y1,x2,y2 never used
}
void confidence::computeConfidence()
{
some calculation
}