简体   繁体   English

错误:ISO C ++禁止声明没有类型的'ref'

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

I have got this error.The code is below: I have integrated vmime libraries in my code.Now i need to implement timeout handler with specific timeout entry 30sec here, as per the requirement so implementing this part of the code. 我有这个错误。代码如下:我已经在我的代码中集成了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>();
        }
};

I tried giving vmime::ref in the place of ref , it gives new error, 我尝试在ref的位置给出vmime :: ref,它给出了新的错误,

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

Can someone please help.Thanks 请有人帮忙。谢谢

EDIT: 编辑:

Iam calling this part of the code in my.C file like this 我在my.C文件中调用这部分代码就像这样

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

Looks like you don't have a type called timeoutHandler but you do have one called myTimeoutHandler . 看起来你没有名为timeoutHandler的类型,但你有一个名为myTimeoutHandler Perhaps you meant: 也许你的意思是:

vmime::ref<myTimeoutHandler>

Or maybe you want the timeoutHandler defined in the vmime::net namespace: 或者,也许你想要的timeoutHandler的定义vmime::net命名空间:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM