2009-11-24 78 views
1

Product.cpp:34:警告: 'QTextStream & ENDL(QTextStream &)' 的地址 , 將始終評估爲 '真'此警告消息的含義是什麼?

Product.cpp:在成員函數「無效 產品: :setProductToSold()':

Product.cpp:45:警告:地址 'QTextStream & ENDL(QTextStream &)', 將始終評估爲 '真'

#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; 
} 

我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 

謝謝:)

+0

線45上面是什麼? – 2009-11-24 20:04:19

回答

7

你(或QT)重新定義ENDL?嘗試把std :: endl

+1

或者把'using std :: endl;'放在另一個'using'聲明的附近。 – Bill 2009-11-24 20:06:18

0

嘗試使用數據隱藏,類成員應該在類的私有部分。
爲什麼在頭文件中包含「HandleTCPClient.h」?

相關問題