求助c++编程错误,谢谢··我想学习学习···
错误为error LNK2001: unresolved external symbol "public: void __thiscall Rectangle::print(void)" (?print@Rectangle@@QAEXXZ)
Debug/22.exe : fatal error LNK1120: 1 unresolved externals
#include<iostream>
using namespace std;
class Rectangle
{
public:
Rectangle(double l=3,double w=5);
~Rectangle()
{
cout<<"count:"<<count;
}
double area();
void display();
void print();
static int count;
private:
double length;
double width;
};
Rectangle::Rectangle(double l,double w)
{
length=l;
width=w;
count++;
}
double Rectangle::area()
{
return(length*width);
}
void Rectangle::display()
{
cout<<"Input length,width:"<<endl;
cin>>length>>width;
}
int Rectangle::count=0;
int main()
{
Rectangle r1(4,9),r2;
r2.display();
r2.print();
r1.print();
return 0;
}
[解决办法]
void print();//只有声明,没有定义