vendredi 22 juin 2018

Why do I get error "'cout' in namespace 'std' does not name a type" when I use "using cout = std::cout;"?

I'm trying to use shorter syntax and avoid using std:: everywhere, so I started using new alias syntax. In some examples I saw people using it this way:

using json = nlohmann::json;

and tried this with std::, but with code below:

#include <iostream>

using cout = std::cout;

int main()
{
    cout << "Sometext";
    return 0;
}

but I get error 'cout' in namespace 'std' does not name a type. I know I can use

using std::cout;

but why using cout = std::cout; doesn't work?

Aucun commentaire:

Enregistrer un commentaire