|
TPoint형을 담고 있는 벡터를 클래스에 선언한 후... 데이터를 무작위로 차곡차곡 때려박습니다.
그리고 나서 벡터를 정렬할려고 하는데요...
클래스 연산자 재정의가 안되어 있다고 에러가 나면서 sort가 되지 않습니다..;;
연산자 재정의 책보고 어케 해볼려고 했는데... 이해가 안갑니다... -_-;;;
어떻게 고치면 되는건지 알려주세요...ㅠㅠ
기본적인 개념도 알려주시면 정말로 감사하겠습니다...
밑에는 클래스와 소스입니다.
-----------------------------------------
//CurveFitting
typedef class TCurveFittingClass
{
private :
std::vector<TPoint> vecDAC;
public:
TCurveFittingClass()
{
vecDAC.reserve(32);
}
void SaveCurvePoint(TPoint curPos)
{
if(vecDAC.size() != 32)
vecDAC.push_back(curPos);
else
ShowMessage("You can't insert points anymore.");
std::sort(vecDAC.begin(), vecDAC.end());
}
TPoint* GetVec()
{
return &vecDAC[0];
}
int GetSize()
{
return vecDAC.size();
}
}TCurve;
TCurve cur;
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
cur = new TCurve;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
cur->SaveCurvePoint(Point(2,20));
cur->SaveCurvePoint(Point(4,20));
cur->SaveCurvePoint(Point(6,20));
cur->SaveCurvePoint(Point(8,20));
cur->SaveCurvePoint(Point(10,20));
cur->SaveCurvePoint(Point(5,20));
std::sort(cur->GetVec(), cur->GetVec()+cur->GetSize()); <---- 에러
//sort 결과는 (2, 20), (4, 20), (5, 20), (6, 20), (8, 20), (10, 20) 이 나와야 됩니다.
//그런데 부분에서 연산자 "<" 가 없다면서 에러가 납니다.
}
//---------------------------------------------------------------------------
|