帮忙解决一个问题。。。。
#include <iostream.h>class CMyRectangle
{
public:
CMyRectangle(double w,double h)
{
width=w;
heigh=h;
cout<<"The object is created!"<<endl;
}
~CMyRectangle()
{
cout<<"The object is destroyed"<<endl;
}
double CalArea();
double CalPerimeter();
private:
double width;
double heigh;
};
double CMyRectangle::CalArea()
{
return width*heigh;
}
double CMyRectangle::CalPerimeter()
{
return (width+heigh)*2;
}
int main()
{
CMyRectangle myerctangle(12.2,9.8);
cout<<"the mianji is:"<<myerctangle.CalArea()<<endl;
cout<<"the zhouchang is"<<myerctangle.CalPerimeter()<<endl;
return 0;
}
这里的w和h已经固定了,如果要手动输入m和h的值,即cin>>该怎么改?
类与对象我一直没弄好懂,谁有详细的教程,顺便给给,谢谢了。。。