mardi 31 août 2021

Error while trying to overload << operator

I can't get the below code to compile while trying to overload the << operator. Can anyone point whats going wrong?

#include <iostream>

std::ostream& operator<<(std::ostream& i, int n)
{
    return i;
}

int main()
{
    std::cout << 5 << std::endl;
    std::cin.get();
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire