请高手帮忙!!!
我是一个C++的初学者,用vs2005来进行编译的。自己建立了一个"win32项目"里面有三个文件:retangle.cpp,retangle.h和picture_retangle.cpp这三个文件,内容如下:
picture_retangle.cpp
#include <iostream>
using std::cout;
using std::endl;
#include "retangle.h"
int main()
{
Retangle retangle(5.2,7.8);
cout < <"The retangle's width is" < <retangle.GetWidth() < <endl;
cout < <"The retangle's length is" < <retangle.GetLength() < <endl;
cout < <"The retangle's area is" < <retangle.area() < <endl;
cout < <"The retangle's perimeter is" < <retangle.Perimeter() < <endl;
return 0;
}
retangle.cpp
#include <iostream>
#include "retangle.h"
Retangle::Retangle(double len, double wid)
{
SetRetangle(len,wid);
}
Retangle::~Retangle()
{}
void Retangle::SetRetangle(double l,double w)
{
Length = (l >= 0.0 && l <= 20.0) ? l : 0;
Width = (w >= 0.0 && w <= 20.0) ? w : 0;
}
double Retangle::GetLength() const
{
return Length;
}
double Retangle::GetWidth() const
{
return Width;
}
double Retangle::area() const
{
return 2 * (Length + Width);
}
double Retangle::Perimeter() const
{
return Length * Width;
}
retangle.h
#ifndef RETANGLE_H
#define RETANGLE_H
class Retangle{
public:
Retangle(double=1.0 ,double=1.0);
~Retangle();
void SetRetangle(double,double) ;
double GetLength() const;
double GetWidth() const;
double Perimeter() const;
double area() const;
private:
double Length;
double Width;
} ;
#endif
在编译阶段时,他显示三个错误如下:
错误 1 error LNK2019: 无法解析的外部符号 _WinMain@16,该符号在函数 ___tmainCRTStartup 中被引用 MSVCRTD.lib
错误 2 fatal error LNK1120: 1 个无法解析的外部命令 C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\2\Debug\2.exe
谢谢!!!