[英]Iterating Over Vector of classes in c++
Song is a class and i want to access one of it's public methods 歌曲是一门课程,我想访问其中的一种公共方法
class RadioManager {
std::vector<Song> all_songs;
public:
void addSong(const Song& song);
}
void mtm::RadioManager::addSong(const Song& song){
vector<Song>::iterator i;
for (i = all_songs.begin(); i != all_songs.end(); ++i) {
i->getSongName(); // When i type i-> i don't get the list of methods in the class song;
}
why it's not showing me contents of the iterator ? 为什么不向我显示迭代器的内容?
If it doesn't show you the content, you can help him. 如果未向您显示内容,则可以帮助他。 (Him being your IDE)
(他是您的IDE)
for (i = all_songs.begin(); i != all_songs.end(); ++i)
{
Song& song = *i;
song.getSongName();
}
the code does all most the same, but then you can QuickWatch and use AutoCompletion about the object song of type Song in your debugger. 该代码的功能几乎相同,但是您可以在调试器中使用QuickWatch并对类型为Song的对象歌曲使用AutoCompletion。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.