모든 노래가있는 CD를 컬렉션에 추가해야합니다. CD 컬렉션에서 CD를 제거하는 방법을 찾으려고합니다. 예를 들어 아티스트 이름, CD 이름, 각 노래의 제목과 길이를 추가하고 표시 기능을 호출하면 모든 정보가 표시됩니다. 아티스트, CD 이름 및 CD 길이를 매개 변수로 사용하여 deleteNode
함수를 호출하면 표시 기능에 내가 추가 한 내용이 계속 표시됩니다. 프로그램이 잘 빌드하지만 나는 deleteNode
함수를 올바르게 호출하지 못한다고 생각합니다. 또한 연결된 목록에는 클래스의 데이터 형식이 있습니다. 나는 그것을 모두 제거에 도착 어떻게 deleteNode
에 대한 매개 변수로 artist
, name
및 length
)를 사용하는 경우노드를 삭제하는 방법
구조체
class CD
{
private:
string artist; // To hold artist nam
string name; // To hold name of CD
struct disc
{
string title; // To hold title of the song
double length; // To hold length of the song
}my_disc;
}
주요
void remove_cd(LinkedList1<CD> *remove)
{
cout << "Enter the name of the artist of the CD you wish to remove: ";
cin.ignore();
getline(cin, artist);
cout << "Enter the title: ";
cin >> title;
cout << "Enter the length: ";
cin >> length;
CD removeNode(artist, title, length);
remove->deleteNode(removeNode);
}
에서 deleteNode
함수를 호출 너무 삽입 된 노래? 내가 필요한 최소한의 코드를 사용하는 것을 시도하고있다
bool CD::operator == (const CD &e)
{
if (artist == e.artist)
return true;
return false;
}
bool CD::operator != (const CD &e)
{
if (artist != e.artist)
return true;
return false;
}
필자는 필요에 따라 최소한의 코드를 사용하려고합니다. 더 이상 코드가 필요한지 알려주세요. – Lilspree
좋아하는 목록 데이터 구조에서 make가 어떻게되는지보십시오. – user1929959