Kinda late in the game here, but I'll reply anyway...
Quote:
int main()
{
int const CAPACITY=5;
Album* data[CAPACITY];
for(int count=0;count<CAPACITY;count++)
{
data[count]= new Album;
data[count]= 0;
}
return 0;
}
|
There is a memory leak here. When you say data[count] = 0, the reference to the recently allocated Album is lost forever. However, what Redhead says is absolutely right. If you are using C++ you never have to deal with Arrays in this sense again, consider the following:
Quote:
#include <vector>
class Album { ; } // <-- implement this
int main() {
int const CAPACITY=5;
std::vector<Album*> albums;
for (int count=0; count<CAPACITY;count++) {
albums.push_back(new Album);
}
}
|
Now you have 5 freshly allocated Album objects, ready for use. To access albums, treat it just like an array:
Quote:
|
album[4]->displaySongList();
|
(or whatever methods are available).