|
궁금 님이 쓰신 글 :
: 포인터.구조체 님이 쓰신 글 :
: : 궁금 님이 쓰신 글 :
: : : [C++ Error] Unit1.cpp(339): E2034 Cannot convert '_Point * *' to 'const tagPOINT *'
: : : 에러가 이렇게 발생하는데염..
: : :
: : : 제 소스...
: : : typedef struct _Point
: : : {
: : : double dx;
: : : double dy;
: : : }SHPPoint;
: : :
: : : typedef struct _PolyLine
: : : {
: : : double xmin;
: : : double ymin;
: : : double xmax;
: : : double ymax;
: : : int NumParts;
: : : int NumPoints;
: : : int *Parts;
: : : SHPPoint *Points;
: : : }SHPPolyLine;
: : :
: : : SHPPolyLine *m_pon;
: : : m_pon = new SHPPolyLine[m_nRecordCnt];
: : :
: : : Polyline(m_hMemDC, m_pon->Points, nNumPoints);
: : : 에서염 m_pon->Points이 틀린것 같은데염..
: : :
: : : POINT p[8];
: : : Polyline(hDC, p, 4);
: : : 이렇게는 되는데.....
: : :
: : :
: : :
: :
: : _PolyLine 구조체의 Points 멤버를
: : a. POINT 배열로 만들든지
: : b. POINT *Points;로 한 다음 메모리를 할당해야 합니다.
: : 물론, Polyline을 호출하여 원하는 다각형을 그리려면 Points의 각 원소에는 좌표가 설정되어 있어야 합니다.
: :
:
: POINT *Points;로 한 다음 메모리를 할당 한 후에 m_pon->Points를 어떻게 해야 할지를...
: 제 생각에는
:
: POINT *p;
: p = new POINT[a];
:
: p->x = m_pon[a].Points[b].dx; 이런식으로 하는게 맞나요??
:
POINt 구조체는 아래와 같습니다.
typedef struct tagPOINT { // pt
LONG x;
LONG y;
} POINT;
SHPPolyLine *ppl=new SHPPolyLine;
ppl->Points = new POINT[n]; //n===점(좌표)의 갯수
ppl->Points[0].x = x좌표1;
ppl->Points[0].y= y좌표1;
ppl->Points[1].x = x좌표2;
ppl->Points[1].y= y좌표2;
.
.
.
ppl->Points[n-1].x = x좌표n;
ppl->Points[n-1].y= y좌표n;
ppl->NumPoints=n;
Polyline(m_hMemDC, ppl->Points, ppl->NumPoints);
ppl을 더이상 사용할 필요가 없을 때는 아래와 같이 메모리를 해제해야 합니다.
delete[] ppl->Points;
delete ppl;
그리고 SHPPolyLine에 생성자를 명시적으로 만들어 점의 갯수를 입력받아 Points에 POINT 인스턴스들을 할당하고, 소멸자도 만들어서 Points를 해제하는 것이 좋겠습니다.
|