开发者

What does this warning message mean?

开发者 https://www.devze.com 2022-12-12 04:39 出处:网络
Product.cpp:34: warning: the address of ‘QTextStream& endl(QTextStream&)’, will always evaluate as ‘true’

Product.cpp:34: warning: the address of ‘QTextStream& endl(QTextStream&)’, will always evaluate as ‘true’

Product.cpp: In member function ‘void Product::setProductToSold()’:

Product.cpp:45: warning: the address of ‘QTextStream& endl(QTextStream&)’, will always evaluate as ‘true’

#include <string>
#include <iostream>
#include <time.h>
using std::string;
using std::cout;

#include "Product.h"

Product::Product()
{
    seller = "";
    itemName = "";
    price = 0.00;
    min = 0.00;
    buyingPrice = 0.00;
    time = 0;
    description = "";
    highestBidder = "None";
    currentBid = 0.00;
    
    timer = new QTimer( this );
    connect( timer, SIGNAL(timeout()), this, SLOT(setProductToSold()) );
}

void Product::startTimer()
{
Line 34:    cout << " Timer Started " << endl;
    timer->start( 2000, TRUE ); // 2 seconds single-shot timer
}

void Product::setHandler(Handler *h)
开发者_如何学运维{
    handler = h;
}

void Product::setProductToSold()
{
Line 45:    cout << " Item auction over" << endl;
}

My Product.h::

#include <string>

#include <qobject.h>
#include <qtimer.h>
#include <qgl.h>

#include "HandleTCPClient.h"

class Handler;

//Define ourselves a product class
class Product : public QObject
    {
    
        Q_OBJECT
    
    
    public:
        Product();
        
        QTimer *timer;
        string seller, itemName, description, highestBidder;
        double price, min, buyingPrice, currentBid;
        int time;
        bool isSold;
        Handler *handler;
        
        void setHandler(Handler *h);
        void startTimer();
        
    public slots:
        void setProductToSold();
        
    };
    
#endif

Thanks :)


Are you (or Qt) redefining endl? try putting std::endl


Try to use data hiding, class members should be in the private part of the class.
Why is #include "HandleTCPClient.h"in the header file?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号