Reputation: 832
I have an albumCollection
, which is of type vector<Album*>
. My Album
class, in turn, holds a vector<Track*>
. This works fine:
for(Album* i : albumCollection) {
cout << i;
}
But trying this:
for(Album* i : albumCollection) {
for (Track* j : i) {
cout << j;
}
}
I get the errors:
no callable 'begin' function found for type 'Album *'
and:
no callable 'end' function found for type 'Album *'
Upvotes: 0
Views: 128
Reputation: 180595
You need the vector that is contained in each Album
to be on the right hand side of the :
in the nested loop. That would look like
for(Album* album : albumCollection) {
for (Track* track : album->name_of_vector) {
cout << track;
}
}
Upvotes: 3