이 함수는 텍스트 파일을 읽고 배열에 문자열을 보낸 다음 해당 배열과 요소 수를 생성자에게 보냅니다. 이제 내 생성자는 동적 인 2D 배열을 생성합니다 (희망). 받은 2 차원 어레이의 행과 열에 배열 값을 할당하고 싶습니다.하나의 배열 내용을 다른 2 차원 배열 rows & colums로 만듭니다.
heres my constructor.
Graph::Graph(string cities[], int n)
{
this->nrOfCities=n;
this->x=n;
this->y=n;
this->graph=new string *[x];
for (int i = 0; i < x; i++)
this->graph[i] =new string[y];
for(int i=0;i<this->x;i++)
for(int j=0;j<this->x;j++)
this->graph[j]=NULL;
for(int i=0;i<=this->x;i++)//I know this last part doesn't work.
for(int j=0;j<this->x;j++)
this->graph[0][j+1]=cities[j];
}
도움의 모든 종류의
에 감사드립니다.
무엇을하기위한 두 번째 외부입니까? 내가 너를 사용하지 않는다면? 또한 세 번째 외부 용. – atoMerz