-1

Song 是一个类,我想访问它的一个公共方法

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;

}

为什么它没有显示迭代器的内容?

4

1 回答 1

1

如果它没有向您显示内容,您可以帮助他。(他是你的 IDE)

for (i = all_songs.begin(); i != all_songs.end(); ++i) 
{
    Song& song = *i;
    song.getSongName(); 
}

代码的作用几乎相同,但是您可以在调试器中快速观看并使用关于 Song 类型的对象歌曲的 AutoCompletion。

于 2013-01-18T13:27:54.230 回答