I'm pretty new to C++, and I'm using std::cout
for debugging purposes.
Though, I'd really like to be able to just use cout
rather than the whole std::cout
thing. I know i could import the std
namespace, but I've been explained it was a bad thing due to name clashing that can occur because of this.
Is there anyway to do this?
I tried
std::ostream cout = std::cout;
But I get
function "std::basic_ostream<_CharT, _Traits>::basic_ostream(const std::basic_ostream<_CharT, _Traits> &) [with _CharT=char, _Traits=std::char_traits<char>]" (declared at line 391 of "/usr/include/c++/5/ostream") cannot be referenced -- it is a deleted function
Please suggest.
std::cout
. – Steeragewaystd
namespace is bad practice. – Steeragewaycout
,endl
, that kind of things), as I stated in my post. – Fredricusing
declarations. Havingusing std;
orusing std::cout;
inside a function or a block in general does not have anything bad. And depending on the case, some may argue that even unscopedusing
is fine in a.cc
/.cpp
file, since it does not affect other compilation units (although I do prefer to avoid that too personally). – Nuzzle