早教吧 育儿知识 作业答案 考试题库 百科 知识分享

如何为以下段落定义Cpointpt和CDC*pDCvoidCTesttwoView::drawstar(Cpointpt,CDC*pDC){doubleg1=0.314;doubleg2=0.628;CPointpt[2]((Nx-nLength*sin(g1)),(Ny+nLength*cos(g1)));CPointpt[3]((Nx+nLength*sin(g1)),(Ny+nLength*cos(g1)));CPoint

题目详情
如何为以下段落定义Cpoint pt和CDC *pDC
void CTesttwoView::drawstar(Cpoint pt,CDC *pDC)
{
double g1=0.314;
double g2=0.628;
CPoint pt[2]((Nx-nLength*sin(g1)),(Ny+nLength*cos(g1)));
CPoint pt[3]((Nx+nLength*sin(g1)),(Ny+nLength*cos(g1)));
CPoint pt[4]((Nx+nLength*cos(g2)),(Ny-nLength*sin(g2)));
CPoint pt[5]((Nx-nLength*cos(g2)),(Ny-nLength*sin(g2)));
pDC-> MoveTo(pt);
pDC-> LineTo(pt[2]);
pDC-> LineTo(pt[4]);
pDC-> LineTo(pt[5]);
pDC-> LineTo(pt[3]);
pDC-> LineTo(pt);
我按你们说的把程序这段变为:
CPoint pt2((pt.x-nLength*sin(g1)),(pt.y+nLength*cos(g1)));
CPoint pt3((pt.x+nLength*sin(g1)),(pt.y+nLength*cos(g1)));
CPoint pt4((pt2.x+nLength*cos(g2)),(pt2.y-nLength*sin(g2)));
CPoint pt5((pt3.x-nLength*cos(g2)),(pt2.y-nLength*sin(g2)));
错误:(44) :error C2061:syntax error :identifier 'Cpoint'
(430) :error C2511:'drawstar' :overloaded member function 'void (class CPoint,class CDC *)' not found in 'CTesttwoView'
本人C++新手,请问应该怎么解决?
▼优质解答
答案和解析
pt就是一个起始点(看上去像是你五角星的顶点),随便设置一个起始点,比如 CPoint pt(100,200).pDC可以是本身view的DC,或者其他窗口的DC,看你想画在哪儿了.
如果想获得本身的DC,就调用GetDC()获得.
还有你代码中pt[2],pt[3]...我觉得不应该是数组,应该是pt2,pt3