And yet, still theres something wrong with it..
you are creating an
Album** with the
Album* album[5];, if you wan't a static one, where you know it's gonna be 5, then use
Album album[5];
Or if you wan't it to be a dynamicaly growing array, then use something like this:
Code:
int maxAlbums = 10;
int numAlbums = 0;
Album* albums;
albums = (Album*) malloc(maxAlbums * sizeof(Album));
if(!albums)
{
fprintf(stderr, "Not enough heap space\n");
exit(-1);
}
while (some_condition)
{
if(numAlbums >= maxAlbums)
{
maxAlbums += 10;
albums = (Album*)realloc(albums, maxAlbums*sizeof(Album));
if(!albums)
{
fprintf(stderr,"Not enough heap space\n");
exit(-1);
}
}
albums[numAlbums++] = new Album;
}
Altho this is C, and not C++. I would guess using some kind of
vector to store it in, would be the right thing to do. And then just use
push and
pop to extend it.