다음과 같은 Animal 개체 배열이 있습니다. >C++ objects array 하나 제거
void AnimalCatalog::Insert(const Animal& animal) {
if(actualSize <= maxSize) {
animalsArray[actualSize] = animal;
actualSize++;
}
}
그리고 내 문제는 내가 아래에있는 내 기능을 사용하여 그것에서 어떤 개체를 삭제할 수있는 방법을 지금 -
Animal animalsArray = new Animal[maxSize];
int actualSize = 0;
내가 거기 개체를 삽입 내 기능을 사용할 수 있습니까?
void AnimalsCatalog::Delete(const char *animalName) {
int index = find(animalName);
< what to write here >
}
find() is my function which return index of the object from the
animalsArray
미리 감사드립니다.
당신은 실제 크기를 통해 색인을 실제 크기 +1을 통해 인덱스 1에서 복사 한 다음 또한 1에 의해 실제 크기를 줄일 수
水 飲 み 鳥 당신은 당신의 코드가 여기에이 기능 쓸 수? – jorge
@jorge - 해결책은 간단합니다. 모든 것을 스크랩하고'std :: vector'를 사용하십시오. – StoryTeller
여기있는 대부분의 사람들이 그렇게 할 수있을 것으로 기대합니다. 그러나 시도하지 않았다면 숙제를하지 않아도됩니다. – drescherjm