PDA

View Full Version : Why this doesn't work? qDebug() << "Test" << std::endl;



grayfox
31st May 2011, 16:35
error: C2228: left of '.nospace' must have class/struct/union

high_flyer
31st May 2011, 16:47
why do you think this should work in the first place?

lsvichet
31st May 2011, 19:23
just write

qDebug()<<"Test";

don't forget to include: #include <QDebug>

dbzhang800
1st June 2011, 02:58
error: C2228: left of '.nospace' must have class/struct/union

You should know that: std::endl is just a template function

declaration:

template <class charT, class traits>
basic_ostream<charT,traits>& endl ( basic_ostream<charT,traits>& os );

and following code is equal:

std::cout<<"hello"<<std::endl;
std::endl(std::cout<<"hello");

MarekR22
1st June 2011, 10:19
std::endl is not supported by qDebug() (QDebug (http://doc.qt.nokia.com/latest/qdebug.html)). This is not a STL stream!
Every qDebug() << somthig << something; creates log in separate line.