using print or using print

I use gcc (Ubuntu 5.4.1-2ubuntu1~16.04) 5.4.1 20160904
#define print std::cout // works for me
however ...
using print = std::cout;
results in :
adefs.hpp:13:27: error: ‘cout’ in namespace ‘std’ does not name a type
using print = std::cout;
Thanks in advance

Michel Chassey
Why do you even attempt to use "print" rather than using the std::cout directly?

The std::cout is name of a global variable.

The using A = B; creates a typename (A) as an alias for an existing typename (B).
An alias declaration creates an alias for a type. eg, using Integer = int ;

std::cout is an object; an alias for an object is a reference.

For example: auto& print = std::cout ; // print is an alias for std::cout
Last edited on
I just remembered from very recent reading that the word
"using" is a kind of typedef, while #define will "____" a new
macro. Didn't have time to edit my post

?Thanks for the fast headsup
Michel Chassey
ps isn't print a command from BASIC ?
Topic archived. No new replies allowed.