compiler error C2678

Trying to compile this project in VS 7, and I'm getting this error:

e:\Program Files\Vc7\atlmfc\include\afxtempl.h(154): error C2678: binary '==' : no operator found which takes a left-hand operand of type 'const CVideoAdapter' (or there is no acceptable conversion)

Looked thru CVideoAdapter class, couldn't find any == comparison being made.
What am I looking at here?

Below is the line from afxtempl.h that compiler complains about:


template<class TYPE, class ARG_TYPE>
BOOL AFXAPI CompareElements(const TYPE* pElement1, const ARG_TYPE* pElement2)
{
      ASSERT(AfxIsValidAddress(pElement1, sizeof(TYPE), FALSE));
      ASSERT(AfxIsValidAddress(pElement2, sizeof(ARG_TYPE), FALSE));

      return *pElement1 == *pElement2; <------------------------------------------- the line
}

Any help is appreciated.
jd9288Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jkrCommented:
Can you post the collection declaration where you are using 'CVideoAdapter' in and if this class has base classes?

You might need to provide your own global

BOOL operator==(const CVideoAdapter& l, const CVideoAdapter& r) {

    // evaluate some criteria that could make two CVideoAdapters 'equal'

    return TRUE;
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AxterCommented:
>>Looked thru CVideoAdapter class, couldn't find any == comparison being made.
>>What am I looking at here?

It looks like the code is using an MFC container class like CMap.

If you're using a sorted container class, then you'll need to provide the operator in order to use your class with the sorted container.
0
jd9288Author Commented:
Here it is. The code is not mine, which complicates things.

class DLL_CLASS CVideoAdapterList : public CList<CVideoAdapter, CVideoAdapter&>  
{
public: // Methods
      //////////////////////////////////
      // Standard contructor/destructor
      //////////////////////////////////
      CVideoAdapterList();
      virtual ~CVideoAdapterList();

};

This supposedly is working in MS Visual C++ 6
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

pb_indiaCommented:
How is this CVideoAdapter defined?
Are you making "==" calls on tjis class?
0
AxterCommented:
Because of your CList inheritance, you need to provide the operator== for class CVideoAdapter
0
jkrCommented:
As I wrote, supply a

BOOL operator==(const CVideoAdapter& l, const CVideoAdapter& r) {

   // evaluate some criteria that could make two CVideoAdapters 'equal'

   return TRUE;
}

for CVideoAdapter and add

friend operator==(const CVideoAdapter& l, const CVideoAdapter& r);

to that class' declaration.
0
jd9288Author Commented:
That solves the problem.
Any idea as to why it would compile in VS 6, but not VS 7?
0
AxterCommented:
VC7 is more compliant with the standard then VC6.

0
jkrCommented:
VC7 is a bit more strict than VC6, that's the only idea I can offer...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.