I am having some problems initialising an array of a type I have created.
I have created "TreeEdge.h" and "TreeNode.h", which can be seen in the following code:
#pragma once
#include "TreeEdge.h"
class TreeNode {
TreeEdge northEdge;
TreeEdge eastEdge;
TreeEdge southEdge;
TreeEdge westEdge;
int xCoord;
int yCoord;
public:
// Default constructor
TreeNode() {
}
//constructor 2
TreeNode(int xInput, int yInput) {
xCoord = xInput;
yCoord = yInput;
}
void setEastSouthEdges(TreeEdge east, TreeEdge south) {
eastEdge = east;
southEdge = south;
}
void setAllTreeEdges(TreeEdge north, TreeEdge east, TreeEdge south, TreeEdge west) {
northEdge = north;
eastEdge = east;
southEdge = south;
westEdge = west;
}
};
and
#pragma once
class TreeEdge {
float weight;
int coords[4];
public:
TreeEdge() {
}
TreeEdge(int firstXCoord, int firstYCoord) {
coords[0] = firstXCoord;
coords[1] = firstYCoord;
}
void setWeight(float inputWeight) {
weight = inputWeight;
}
float getWeight() {
return weight;
}
void setStartCoords(int xCoord, int yCoord) {
coords[0] = xCoord;
coords[1] = yCoord;
}
int * getCoords() {
return coords;
}
void setEndCoords(int xCoord, int yCoord) {
coords[2] = xCoord;
coords[3] = yCoord;
}
};
I am then trying to simply initialise an array of TreeNode, in the hope of doing something useful with it, using the following code...
#include "stdafx.h"
#include <opencv2/opencv.hpp>
#include <stdio.h>
#include "TreeEdge.h"
#include "TreeNode.h"
using namespace cv;
using namespace std;
int main()
{
// create 2D array for tree
TreeNode imageTreeNodes[544][1024]; // ???????????????? way to use none fixed values
waitKey(0);
return 0;
}
However, I am getting an error: "Unhandled exception at 0x00007FF6E91493D8 in MST.exe: 0xC00000FD: Stack overflow (parameters: 0x0000000000000001, 0x0000002BFF003000)." as soon as the program enters the main function.
Thanks for your help.
Rob