작성한 유형의 배열을 초기화하는 데 문제가 있습니다.C++ 스택 오버플로 초기화 배열
다음 코드에서 볼 수있다 "TreeEdge.h"와 "TreeNode.h"를 만들었습니다
#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;
}
};
및
#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;
}
};
나는 단순히 초기화하려고
다음 코드를 사용하여 유용한 정보를 얻기 위해 TreeNode의 배열을 만듭니다. ...
그러나, "처리되지 않은 예외가 MST.exe의 0x00007FF6E91493D8에 있습니다. 0xC00000FD : 스택 오버플로 (매개 변수 : 0x0000000000000001, 0x0000002BFF003000).는 "즉시 프로그램은 메인 함수를 입력한다.
감사를 도와.
롭
'의 TreeNode의 imageTreeNodes [544] [1024] : 그래서 뭔가를 찾도록
main()
을 변경. –Gaurav Sehgal이 제안한 것과 달리 프로그램에 의해 할당 된 스택의 양을 늘릴 수 있습니다. VS20xx에는 아마 다른 컴파일러에서 그런 옵션이 있다는 것을 기억합니다. – Scheff
[SO : GNU 컴파일러로 컴파일하는 동안 Linux에서 C++ 응용 프로그램의 스택 크기 변경] (https://stackoverflow.com/q/2275550/7478597) 및이 [MSDN :/F (스택 크기 설정)] (https://msdn.microsoft.com/en-us/library/tdkhxaks.aspx). – Scheff