无法使用std :: end打印字符串

A.d*_*vid 0 c++ linux ubuntu c++11

我在使用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);
}
Run Code Online (Sandbox Code Playgroud)

这是我编译时得到的错误:

"error: no match for ‘operator<<’ (operand types are ‘std::basic_ostream<char>’ and ‘<unresolved overloaded function type>’)" 
Run Code Online (Sandbox Code Playgroud)

这个错误来自我给你的函数中的cout行.

我在Linux Ubuntu上使用Geany并使用c ++ 11.

谢谢你的帮助

And*_*dyG 5

std::end() 是一个将迭代器放到容器末尾的函数.

您的意思是使用std::endl流操纵器.

注意:避免using namespace std;在您的实际代码中,要么利用using指令只引入您需要的内容,要么使用其命名空间的限定名称,就像我在这里一样.