Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: 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;
}
 
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 19-Jun-12 4:48am
Edited 19-Jun-12 5:17am
v2
Comments
Sergey Alexandrovich Kryukov at 19-Jun-12 11:01am
   
(Sigh...)
--SA
Sandeep Mewara at 19-Jun-12 11:18am
   
Is not that similar to :doh:
 
:)

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
Comments
Sandeep Mewara at 19-Jun-12 11:18am
   
5! :)
 
BTW, super name Sergey! :)
Sergey Alexandrovich Kryukov at 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 at 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 at 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)

  Print Answers RSS
0 OriginalGriff 6,649
1 Sergey Alexandrovich Kryukov 6,270
2 CPallini 5,190
3 George Jonsson 3,574
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 19 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100