I come to you for a strange problem when I use the Visual Studio Native Unit Test on VS 2012. I've a Coordinates class like that:
#ifndef COORDINATES_HPP
#define COORDINATES_HPP
#include <iostream>
namespace Core {
class Coordinates {
public:
Coordinates();
Coordinates( int x, int y );
Coordinates( const Coordinates © );
~Coordinates();
void operator=( Coordinates coordinates );
void operator+=( Coordinates coordinates );
void operator-=( Coordinates coordinates );
Coordinates operator+( Coordinates coordinates );
Coordinates operator-( Coordinates coordinates );
bool operator==( Coordinates coordinates );
bool operator!=( Coordinates coordinates );
int getX() const { return m_x; }
int getY() const { return m_y; }
void setX( const int &val ) { m_x = val; }
void setY( const int &val ) { m_y = val; }
protected:
int m_x, m_y;
};
}
So the problem appear when I use : Assert::AreEqual( Coordinates(0,0), Coordinates(0,0) );
The error sended is : Error 1 error C2678: binary '==' : no operator found which takes a left-hand operand of type 'const Core::Coordinates' (or there is no acceptable conversion) c:program files (x86)microsoft visual studio 11.0vcunittestincludecppunittestassert.h 129 1 UnitTest1
Do you have an idea for fix that?
PS: Sorry for my english, is not my native language.
See Question&Answers more detail:os