我在做VC++时,我做了下面一个实验:
void CMyView::OnDraw(CDC* pDC)
{
CMyDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
const int xOrg=50;
const int yOrg=450;
const int xMax=800;
const int yMin=20;
pDC->MoveTo (xOrg,yOrg);
pDC->LineTo(xMax,yOrg);
pDC->MoveTo(xOrg,yOrg);
pDC->LineTo(xOrg,yMin);
pDC->MoveTo(101,320);
pDC->LineTo(182,100);
pDC->LineTo(200,200);
pDC->LineTo(320,330);
pDC->LineTo(500,210);
pDC->LineTo(520,180);
pDC->LineTo(550,143);
pDC->LineTo(586,88);
pDC->LineTo(612,45);
int x=(xMax-xOrg)/2;
int y=yOrg+10;
pDC->TextOut (x,y,"Force");
x=xOrg-20;
y=(yOrg-yMin)/2;
pDC->TextOut(x,y,"D");
y+=15;
pDC->TextOut(x,y,"i");
y+=15;
pDC->TextOut(x,y,"p");
}
编译时没有出现错误,但在链接时就不行了,出现这样的错误:
Linking...
画点View.obj : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const CMyDoc::classCMyDoc" (?classCMyDoc@CMyDoc@@2UCRuntimeClass@@B)
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
libcd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/画点View.exe : fatal error LNK1120: 4 unresolved externals
执行 link.exe 时出错.
画点View.exe - 1 error(s), 0 warning(s)
这是怎么回事啊,我以前问过一个人,说是在一开始编程时就链接就没这样的错误,我试了,是这样的,可我现在是改了它啊,我现在怎么可能一开始就链接呢,现在是不可能的啊,除了你重做,这是为什么啊