Click here to Skip to main content
15,880,905 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All,

In my VC++ Application, I have been unable to resolve the following code snippet (similar),....
C++
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;
}


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
Posted
Updated 19-Jun-12 5:17am
v2
Comments
Sergey Alexandrovich Kryukov 19-Jun-12 11:01am    
(Sigh...)
--SA
Sandeep Mewara 19-Jun-12 11:18am    
Is not that similar to :doh:

:)

1 solution

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
 
Share this answer
 
Comments
Sandeep Mewara 19-Jun-12 11:18am    
5! :)

BTW, super name Sergey! :)
Sergey Alexandrovich Kryukov 19-Jun-12 11:21am    
This is nothing but my real original name spelled in full. I'm tired of confusing people with my abbreviated name so they did not know how to address to me. The root of the problem is: my official English spelling "Sergey A Kryukov" was already taken as a CodeProject ID by another guy, so I always was uncomfortable with mine. All three parts of my name are so usual in Russians so I have a good number of exact namesakes, in a fully-spelled name.
--SA
Sandeep Mewara 21-Jun-12 16:57pm    
:)
Strange for me that a name like 'Sergey A Kryukov' was already taken as a CodeProject ID by another guy!
Sergey Alexandrovich Kryukov 29-Jun-12 20:51pm    
There are very many people with similar name, where are one or two parts of name are the same, so not wonder there is one complete namesake...
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900