<分区>
我在用 C++ 打印字符串时遇到问题。
我知道在 SO 上有很多关于这个问题的话题,但大多数人说要包括 <string>
, <iostream>
或 namespace std
.但是我做了所有这些但仍然遇到问题。这是我的代码和错误。
#include <iostream>
#include <string>
using namespace std;
//...
void affiche_date(int annee, int nbjours) {
string mois;
if (nbjours>31) {
mois = "avril";
nbjours -= 31;
} else {
mois = "avril";
}
cout << "Date de Paques en " << annee << " : " << nbjours << " " << mois << end;
}
int main() {
int annee ( demander_annee() ) ;
int jour ( date_paques(annee) );
affiche_date(annee, jour);
}
这是我在编译时遇到的错误:
"error: no match for ‘operator<<’ (operand types are ‘std::basic_ostream<char>’ and ‘<unresolved overloaded function type>’)"
这个错误来 self 给你的函数中带有 cout 的行。
我在 Linux Ubuntu 上使用 Geany 并使用 c++11。
谢谢你的帮助