小编Chr*_*ine的帖子

比较c ++字符串

class Song {

public:
    const string getAutherName();
}

void mtm::RadioManager::addSong(const Song& song,const Song& song1) {

    if (song.getAutherName() == song1.getAutherName())

}
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

Invalid arguments ' Candidates are: std::basic_string<char,std::char_traits<char>,std::allocator<char>> getAutherName() ' - passing 'const mtm::Song' as 'this' argument of 'std::string mtm::Song::getAutherName()' discards qualifiers [- fpermissive]
Run Code Online (Sandbox Code Playgroud)

它为什么使用basic_string而不是string!怎么解决这个问题?

c++ string compare

3
推荐指数
1
解决办法
151
查看次数

复制类构造函数C++

我有一首我要复制的歌曲......

int mtm::Song::getLimitedLength(int maximum_length) {

        Song copied_song(this);
    this->Song(copied_song);
}
Run Code Online (Sandbox Code Playgroud)

我收到这个错误:

Multiple markers at this line
- candidates are:
- no matching function for call to 'mtm::Song::Song(mtm::Song* const)'
Run Code Online (Sandbox Code Playgroud)

c++

1
推荐指数
1
解决办法
115
查看次数

标签 统计

c++ ×2

compare ×1

string ×1