2013-01-18 103 views
0

宋是一類 ,我想訪問它的一個公共方法遍歷矢量++

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; 

} 

它爲什麼不顯示我的迭代器的內容是什麼?

+0

它給編譯器錯誤嗎? –

+4

大概你在談論你的IDE的某些功能,也許是Intellisense?你應該說清楚。你的問題不是關於C++,而是關於你的IDE –

回答

1

如果它沒有顯示你的內容,你可以幫助他。 (他是你的IDE)

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

代碼做了所有最相同的,但你可以快速監視和使用的AutoCompletion約Song類型在調試器對象歌曲。

+0

作品....謝謝 – Christine

+0

@Christine歡迎SO! –