簡體   English   中英

錯誤:ISO C ++禁止聲明沒有類型的'ref'

[英]error: ISO C++ forbids declaration of 'ref' with no type

我有這個錯誤。代碼如下:我已經在我的代碼中集成了vmime庫。現在我需要在這里實現具有特定超時條目30秒的超時處理程序,根據要求實現這部分代碼。

class myTimeoutHandler : public vmime :: net :: timeoutHandler {
    public:
     bool isTimeOut()
    {
        return(getTime()>=m_last + 30);
    }
    void resetTimeOut()
    {
        m_last = getTime();
    }
     bool handleTimeOut()
    {
        logMsg(DEBUG,2,"Connection Timed Out!");
        return true;
    }
private:

 const unsigned int getTime() const

 {
    return vmime::platform::getHandler()->getUnixTime();
 }
unsigned int m_last;
};

class myTimeoutHandlerFactory : public vmime::net::timeoutHandlerFactory
{
    public:
        ref <timeoutHandler> create ()
        {
            return vmime::create <myTimeoutHandler>();
        }
};

我嘗試在ref的位置給出vmime :: ref,它給出了新的錯誤,

Svr.h:158: error: 'timeoutHandler' was not declared in this scope
Svr.h:158: error: template argument 1 is invalid

請有人幫忙。謝謝

編輯:

我在my.C文件中調用這部分代碼就像這樣

tr->setTimeoutHandlerFactory(vmime::create <myTimeoutHandlerFactory>());

看起來你沒有名為timeoutHandler的類型,但你有一個名為myTimeoutHandler 也許你的意思是:

vmime::ref<myTimeoutHandler>

或者,也許你想要的timeoutHandler的定義vmime::net命名空間:

vmime::ref<vmime::net::timeoutHandler>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM