我觉得非常愚蠢不得不寻求帮助,但我正在拔头发。
我有这个 printSong() 函数,可以从歌曲数据库中打印歌曲信息。
void Song::printSong(int &i)
{
cout << right << i+1 <<") "<< songName << '\t' << artist << '\t'<< internal
<< setfill('0') << setw(2) << min << ":" << internal << setfill('0')
<< setw(2) << sec << '\t' << album << endl;
}
我从这个函数中调用它:
void SongList::displayAll(int &numSongs, int &i)
{
clearScreen();
cout << "Index" << '\t' << "Song "<< '\t' << '\t'
<< "Artist " <<'\t' << '\t'<< "Time" << '\t' << "Album" << endl;
cout << "******************************************************************************"<< endl;
for(int i = 0; i < 12; i++)
{
list[i].printSong(i);
}
cout << "numSongs = " << numSongs << endl;
cout << "Press enter to return to the menu: ";
}
打印时,它会在打印索引号后转到新行。例如,它应该如下所示:
1) House of Cards Radiohead 05:28 In Rainbows
但我得到的是:
1
) House of Cards Radiohead 05:28 In Rainbows
我无法弄清楚它为什么这样做。有任何想法吗?
谢谢!