probolem: link error : unresolved external symbol __thiscall ... operator ==...
//MyPolygenDlg.cpp
#include "stdafx.h"
#include "linkerror.h"
#include "linkerrorDlg.h"
#include "Polygon.h"
#include "Vertex.h"
using namespace std;
....
void ClinkerrorDlg::OnBnClickedOk()
{
UpdateData(TRUE);
//initialize begin
CVertex ver1(1,1);
CVertex ver2(2,2);
CVertex ver3(3,4);
vector<CVertex> arrV;
arrV.push_back(ver1);
arrV.push_back(ver2);
arrV.push_back(ver3);
//initialize end
SortPolyPoints(arrV); //see polygon.cpp
UpdateData(FALSE);
}
//Polygon.h
#ifndef _POLYGON_H
#define _POLYGON_H
#include "Vertex.h"
#include <vector>
void SortPolyPoints(std::vector<CVertex> &);
#endif
//Polygon.cpp
#include "stdafx.h"
#include "Vertex.h"
#include <vector>
using namespace std;
void CleanUp(vector<CVertex> & arrV)
{
for(int i=0; i<arrV.size(); i++)
{
for(int j=arrV.size()-1; j>i; j--)
{
if(arrV[i] == arrV[j]) //link error here, under VC6.0
arrV.erase(arrV.begin()+j); //unresolved external symbol ...
__thiscall ... operator== ...
} //but when I went home and
rebuild all under VC2008
} //there is no error message.
why and how can I handle this?
//thank you
very much
}
void SortPolyPoints(std::vector<CVertex> & arrVer)
{
//1. clear same elements
CleanUp(arrVer);
}
//Vertex.h
#ifndef _VERTEX_H
#define _VERTEX_H
class CVertex
{
public:
CVertex(double = 0, double =0);
CVertex(const CVertex &);
BOOL operator == (const CVertex &) const;
double m_dX, m_dY;
};
#endif
//Vertex.cpp
#include "stdafx.h"
#include "Vertex.h"
CVertex::CVertex(double dX, double dY)
{
m_dX = dX;
m_dY = dY;
}
CVertex::CVertex(const CVertex & verDest)
{
if(this != &verDest)
{
m_dX = verDest.m_dX;
m_dY = verDest.m_dY;
}
}
BOOL CVertex::operator ==(const CVertex & verDest) const
{
if( (m_dX == verDest.m_dX) && (m_dY == verDest.m_dY) )
return TRUE;
else
return FALSE;
}