class Song {
public:
const string getAutherName();
}
void mtm::RadioManager::addSong(const Song& song,const Song& song1) {
if (song.getAutherName() == song1.getAutherName())
}
我收到了这个错误信息:
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]
为什么要使用basic_string
而不是string
?如何解决这个问题?
std::basic_string<...
只是在后台使用的实际内容。错误仍然与您对std::string
的使用有关。 - stefan==
被重载并允许进行字符串相等比较。 - wklC++
不是 Java。 - Ivaylo Strandjevstd::string
只是std::basic_string<char>
的一个typedef
。 - cschwangetAutherName()
不是常量,我认为你不能使用那些 Song 引用来调用它。 - Mat