If you use Qt and endlendl, you could accidentally use the wrongend up using an incorrect endl, happened to me today and i was like . which gives you very surprising results.WTF ?? See the following code snippet:
#include <iostream>
#include <QtCore/QtCore>
#include <QtGui/QtGui>
// notice that i dontthere haveis ano "using namespace std;"
int main(int argc, char** argv)
{
QApplication qapp(argc,argv);
QMainWindow mw;
mw.show();
std::cout << "Finished Execution !" << endl << "...";endl;
// LineThis aboveprints printedsomething similar to: "Finished Execution !67006AB4..."67006AB4"
return qapp.exec();
}
Of courseNote that was my mistake, since i should have writtenI wrote endl instead of std::endl, but if you use *endl, qt and using namespace std; it depends on the order of the include files if the correct endl will be used.
Of course you could recompile Qt to use a namespace, so you get(which would have been correct) and apparently there is a compilation error for the example above.
EDIT: Forgot to mention, Qt's endl is declaredfunction defined in "qtextstream.h" whichqtextstream.h (which is part of QtCore).
*EDIT2: C++ will pick the correct endl if you have a using for std::cout or the namespaceUsing std"\n", since instead of std::endl completely sidesteps any potential namespace issues.
This is inalso a good example why putting symbols into the sameglobal namespace as std::cout, C++'s ADL mechanism will pick std::endl(like Qt does by default) is a bad idea.