问题描述
所以我试图制作一个“播放列表”程序,其中每个艺术家的名字都存储在一个艺术家链接列表的自己的节点中,然后每个艺术家都有自己的链接列表,其中每个节点都是该艺术家的歌曲。我的程序能够创建一个艺术家列表,但是我不知道如何将歌曲列表连接到艺术家列表的节点。有人可以帮我了解我的班级或“添加歌曲”功能的外观吗?
标题
#include <iostream>
#include <cstring>
using namespace std;
struct songNode
{
char* Title = new char[25];
songNode* next;
songNode()
{
next = 0;
}
};
struct artistNode
{
char* artistName = new char[25];
artistNode* next;
artistNode()
{
next = 0;
}
};
class artistClass
{
public:
artistClass() //constructor
{
head = NULL;
}
//~recordLabel(); //destructor
void addArtist(char* artistName);
void displayArtists();
void addSong();
private:
//songNode* head; Should this be here?
artistNode* head;
};
recordlabel.cpp
void artistClass::addArtist(char* artistName)
{
artistNode* temp = new artistNode;
temp->artistName = new char[strlen(artistName) + 1]; //add artist name to node
strcpy(temp->artistName,artistName);
temp->next = head;
head = temp;
}
P.S。我故意不使用字符串。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)