如何解决VC ++中的w.r.t类型转换错误 [英] How to resolve the error w.r.t conversions of types in VC++

查看:53
本文介绍了如何解决VC ++中的w.r.t类型转换错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

在我的VC ++应用程序中,我无法解析以下代码段(类似),....

Hi All,

In my VC++ Application, I have been unable to resolve the following code snippet (similar),....

Class B : public A
{
public:

   bool f1();
   bool f2();
   UINT8* rawmem;
};

B objb;

bool B::f1()
{
   rawmem = (UINT8*) new [200];
return true;
}

bool B::f2()
{
   ECODE ec;

   ...
   if(ec = (objb.rawmem) != EC_NO_ERR)   {
     SaveToLog(ERR_MSG, " Objb creation failed 0x%x",ec);
     return false;
   }
   ....
   return true;
}



在上面的代码的构建上:我得到C2679:错误,指出>>二进制``!='':未找到采用ECODE类型的右侧操作数的运算符(或没有可接受的转换).

我怀疑上面突出显示的错误是由于运算符重载(!=)或所述行括号中的不匹配.我需要一些帮助来解决上述错误.(无助于reinterpret_cast)

在此先感谢...

问候,
Vishalk_91



On build of above code: I am getting C2679: error which states >> binary ''!='' : no operator found which takes a right-hand operand of type ECODE(or there is no acceptable conversion).

I suspect the error highlighted above is either because of want of operator overloading (!=) OR mismatch in parenthesis for the said line. I need some help in resolving the above error.(without resorting to reinterpret_cast)

Thanks in Advance...

With Regards,
Vishalk_91

推荐答案

您正在尝试将指针的值与一些表示无错误"的整数常量进行比较.它不仅不能编译,而且根本没有任何意义.如果设法转换"它(键入强制转换),只会使情况变得更糟.您真的了解指针的作用吗?

—SA
You are trying to compare a value of the pointer with, I guess, some integer constant indicating "no error". Not only it cannot compile, it makes no sense at all. If you managed to "convert" it (type cast), you would only make things worse. Do you really understand what a pointer does?

—SA


这篇关于如何解决VC ++中的w.r.t类型转换错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆