以下代码是教程的一部分。我已经根据教程检查了无数次代码,虽然它适用于视频,但我的程序有以下错误:
1>------ Build started: Project: simpleclass, Configuration: Debug Win32 ------
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall rectangle::rectangle(void)" (??0rectangle@@QAE@XZ) referenced in function _main
1>C:\Users\Bob K\Documents\Visual Studio 2010\Projects\simpleclass\Debug\simpleclass.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
这是代码:
#include <iostream>
class rectangle
{
private:
double length;
double width;
public:
rectangle();
~rectangle();
double calcperim() const;
double calcarea() const;
double getlength() const;
double getwidth() const;
void setlength(double l);
void setwidth(double w);
};
rectangle::~rectangle()
{
}
double rectangle::calcperim() const
{
return ( length + length + width + width);
}
double rectangle::getlength() const
{
return length;
}
double rectangle::getwidth()const
{
return width;
}
void rectangle::setwidth( double w)
{
width = w;
}
void rectangle::setlength(double l)
{
length = l;
}
double rectangle::calcarea() const
{
return (length * width);
}
int main()
{
using namespace std;
rectangle r;
r.setwidth(3);
r.setlength(9);
cout << "length " << r.getlength() << endl;
cout << "width " << r.getwidth() << endl;
cout << "perimiter: " << r.calcperim() << endl;
cout << "Area: " << r.calcarea() << endl;
system("pause");
return 0;
}
请帮忙。几年前我曾经编程过,现在我正在尝试重新开始编程。