尝试使用 C++ 中的类中的 vector 进行迭代:
for(vector<Album>::iterator it = a.getAlbumList.begin(); it != a.getAlbumList.end(); it++)
但它给了我错误:
error: 'a.AlbumCollection::getAlbumList' does not have class type
这让我很沮丧,因为我不知道这意味着什么,并且我尝试遵循其他建议但没有帮助。我只是一个初学者,所以如果有人可以简单地向我解释这一点,那就太好了,谢谢。
这是类(class):
.cpp:http://pastebin.com/MSCcHjXb
.h:http://pastebin.com/Xq4nqSan
最佳答案
您(显然)想要调用 getAlbumList
成员函数,因此您的代码应该是:
for(vector<Album>::iterator it = a.getAlbumList().begin();
it != a.getAlbumList().end();
it++)
关于c++ - 没有类(class)类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13814269/