std::find == problem, probably obvious
Posted: Fri Jun 10, 2011 12:55 am
Hey guys, couldn't figure this out before I went to sleep. Probably make more sense in the morning (yawn, finished my last final today!), but if anyone is bored and sees the problem, let me know!
And the Point2D class:
// error message
ty ty ty
Code: Select all
//determine if shape contains a point
inline bool ContainsPoint(const Point2D& point) {
return std::find(_relativePoints.cbegin(), _relativePoints.cend(), point) != _relativePoints.cend() ? true : false;
}
Code: Select all
// decleration of _relativePoints
private:
// array of shape vertices
Point2D _centralPoint;
std::vector<Point2D> _relativePoints;
Code: Select all
#ifndef _POINT2D_H_
#define _POINT2D_H_
class Point2D
{
public:
explicit Point2D(void);
Point2D(float x, float y);
~Point2D(void);
inline float X() { return _x; }
inline float Y() { return _y; }
inline void X(float x) { _x = x; }
inline void Y(float y) { _y = y; }
private:
float _x;
float _y;
};
#endif
Code: Select all
#include "Point2D.h"
// default constructor
Point2D::Point2D(void)
{
_x = _y = 0.0f;
}
// constructor taking x and y
Point2D::Point2D(float x, float y)
{
X(x);
Y(y);
}
Point2D::~Point2D(void)
{
}
Code: Select all
Error 1 error C2678: binary '==' : no operator found which takes a left-hand operand of type 'Point2D' (or there is no acceptable conversion) c:\program files\microsoft visual studio 10.0\vc\include\algorithm 41