次のコードはチュートリアルの一部です。チュートリアルと照らし合わせてコードを何度もチェックしましたが、ビデオでは機能しますが、私のプログラムには次のエラーがあります。
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;
}
助けてください。私は何年も前にプログラミングをしていましたが、それをやり直そうとしています。