그리드에서 두 점 사이의 최단 경로를 찾는 프로그램을 만들려고합니다. 그래서 나는 FinalPath
이라는 클래스를 만들었고, 북쪽, 남쪽, 동쪽 및 서쪽의 한 걸음 인 주변 지역의 위치를 추적하려고합니다.C++ 프로그램에서 클래스 내에서 같은 클래스의 인스턴스를 만드는 방법
이 배열을 저장하려면 Final
클래스 유형의 배열 인스턴스를 만들었지 만 프로그램을 실행하려고하면 error-"error:field 'Find' has incomplete type of "FindPath[4]" "
이 표시됩니다. 컴파일러는 클래스의 인스턴스를 생성하는 나에게 오류를 보여주는 이유가 궁금
#include <iostream>
#include<vector>
using namespace std;
int a=0,b=0,g=0;
class FinalPath
{
public:
vector<vector<int> >inputMat;
vector<vector<int> >saveMat[4];
int dist;
int goal[2];
int next[4][2];
FinalPath Find[4];
};
를 따를 때 내가 클래스에 입력
코드는? 같은 클래스의 인스턴스를 만드는 올바른 방법은 무엇입니까? image of code and error console
처럼, 대신 클래스에 대한 포인터를 사용하여 어떻게 컴파일러는이 데이터 구조의 크기를 해결할 수 있습니다 생각하십니까? –
코드 사진을 게시하지 마십시오. –
가능한 중복 : http://stackoverflow.com/questions/1021740/can-a-class-be-self-referenced – bigahega