求助:lnk2001的问题!!
我用的是vc6编译器,学习c++
程序如下:
#include <iostream>
using namespace std;
enum CHOICE {DrawRect=1,GetArea,GetPerim,ChangeDimensions,Quit};
class Rectangle
{
public:
Rectangle(int width,int height);
~Rectangle();
int GetHeight();
int GetWidth();
int GetArea();
int GetPerim();
void SetSize(int newWidth,int newHeight);
private:
int itsWidth;
int itsHeight;
};
Rectangle::Rectangle(int width,int height)
{
itsWidth=width;
itsHeight=height;
}
Rectangle::~Rectangle(){}
int Rectangle::GetWidth()
{
return itsWidth;
}
int Rectangle::GetHeight()
{
return itsHeight;
}
int Rectangle::GetArea()
{
return (itsWidth*itsHeight);
}
int Rectangle::GetPerim()
{
return (2*itsWidth+2*itsHeight);
}
void Rectangle::SetSize(int newWidth,int newHeight)
{
itsWidth=newWidth;
itsHeight=newHeight;
}
int DoMenu();
void DoDrawRect(Rectangle);
void DoGetArea(Rectangle);
void DoGetPerim(Rectangle);
int main()
{
Rectangle theRect(30,5);
int choice=DrawRect;
int fQuit=false;
while(!fQuit)
{
choice=DoMenu();
if (choice<DrawRect||choice>Quit)
{
cout<<"\nInwalid choice,please try again.\n";
continue;
}
switch(choice)
{
case DrawRect:
DoDrawRect(theRect);
break;
case GetArea:
DoGetArea(theRect);
break;
case GetPerim:
DoGetPerim(theRect);
break;
case ChangeDimensions:
int newWidth,newHeight;
cout<<"\nNew width: ";
cin>>newWidth;
cout<<"\nNew height: ";
cin>>newHeight;
theRect.SetSize(newWidth,newHeight);
DoDrawRect(theRect);
break;
case Quit:
fQuit=true;
cout<<"\nExit...\n\n";
break;
case false:
cout<<"\nError in choice!\n";
fQuit=true;
break;
}
}
return 0;
}
int DoMeun()
{
int choice;
cout<<"\n\n *** Menu ***\n";
cout<<"(1) Draw Rectangle\n";
cout<<"(2) Area\n";
cout<<"(3) Peimeter\n";
cout<<"(4) Resize\n";
cout<<"(5) Quit\n";
cin>>choice;
return choice;
}
void DoDrawRect(Rectangle theRect)
{
int height=theRect.GetHeight();
int width=theRect.GetWidth();
for(int i=0;i<height;i++)
{
for(int j=0;j<width;j++)
cout<<"*";
cout<<"\n";
}
}
void DoGetArea(Rectangle theRect)
{
cout<<" Area: "<<theRect.GetArea()<<endl;
}
void DoGetPerim(Rectangle theRect)
{
cout<<" Perimeter: "<<theRect.GetPerim()<<endl;
}
编译没有问题!
连接问题如下:
--------------------Configuration: R1_1 - Win32 Debug--------------------
Linking...
R1_1.OBJ : error LNK2001: unresolved external symbol "int __cdecl DoMenu(void)" (?DoMenu@@YAHXZ)
Debug/R1_1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
R1_1.exe - 2 error(s), 0 warning(s)
请问各位,问题在哪里?如何解决???
谢谢了!!!