samedi 30 septembre 2023

Makin an array of objects without knowing how many objects are going to be there (c++)

This is something that can be done easily with vectors/linked lists but I'm limited to the use of only dynamic arrays... I'm supposed to create a playlist program which stores different playlists and each playlist can have as many songs as user adds to it. How do I solve this problem without putting a max-cap on the number of songs that can be stored in a playlist?

What I've currently thought so far is making 2 classes, "songs" and "playlist", And include a dynamic array of "songs" class inside the playlist class....

class Playlist{
Songs* song = new Songs[10];
};

This will not work for me as it still puts a cap of 10 songs in the playlist...

edit: you can see the given problem here

Aucun commentaire:

Enregistrer un commentaire