Mine is a project in Visual C++, in which I am using STL, and trying to use the "find" algorithm with vectors. But it's giving me the error, error C2678: binary '==' : no operator found which takes a left-hand operand of type 'xyz' (or there is no acceptable conversion), because I have an app class in MFC which has a structure 'xyz' whose only member is a BYTE array. I am trying to get the iterator position by finding a value in a vector of a user-defined type and in return I am getting the above error. Hence a problem. Please help.
someone can also suggest, which algorithm should I use to get the iterator position of the value I am searching for,from a vector of a user-defined data type (you can suggest that algorithm from the boost library also)?
Thanks in advance. This is urgent.
Here is the relevant code snippet to understand the problem:
In the header,
typedef struct xyz
class CMyApp : public CWinApp
Many thanks for this solution, I fully appreciate it. Coincidentally, I had already implemented this, but since this was taking time in checking a database which is huge in size, I was looking for some other algorithm which will give a quicker result. Could you please suggest a better algorithm which will save me from using memcmp?
First of all, many thanks for your solution. Although it has solved my operator == overloading question, but I have one more difficulty, may be a strange experience. The find algorithm of STL is not giving the iterator position, even if the item to be searched is located in the BYTE array. Does it have anything to do with the size of the arrays as well? because one BYTE array is of 16 bytes, and the one it is to be compared with is of 33 bytes? In such a case, how can I make the find algorithm give me the correct answer? Please help.
Thanks in advance.
You can put any code into a DLL. It is even simpler and better when the DLL code did not use MFC or ATL (it can then be used by any application).
I'm not sure if I understand your second question. Do you mean to create a DLL with functions used by multiple applications where each application uses only a subset of exported functions?
If so, the answer is yes.
To list the symbols exported by a DLL you can use the DUMPBIN[^] command line tool (located in the VC\bin directory) with the /EXPORTS option.
I am doing Interprocess communication between a C console app and C++ Windows app
The C console app is the parent process
I have the Window handle (main window MainFrame) of the C++ child app I use SendNotifymessage
to tell the child app that console app has data for it in shared storage
The First time I do this all is well
The Second time around I have created a modless dialog box with a Crichedit control
it is at this time where I get a asseration from the SendNotifyMessage in the console C app
The assetration is dlgcore.cpp
at the parent GetSafeHWnd
But the Window Handle is a Main or Mainframe Window
I did a FindWindow api call
To get the handle As the parent is a C console app and it did work once before I created the modless dialog box in the child process
No, you just need to find its handle by one of the enumerate functions, or get the child to pass it back in some way. A handle is just a pointer used to identify a Window so you can send messages to it. To be honest, I am not exactly clear about what you are trying to do beyond the basic SendMessage function.