السلام عليكم ورحمه الله وبركآته
فيه خطأ بالكلاس ما ادري ليـه
طبعاً البرنامج للمستطيل يحسب المساحه والمحيط
وهذا الكود .. فيه خطأ ما ادري ايش ..
#include<iostream.h>
class Rectangle
{
public:
Rectangle(){ a = b = 0.1;}
float set(float , float);
float get(float , float);
float area( float , float);
float p(float , float );
private:
float a,b;
}
float Rectangle::set( float f1 , float f2)
{
a = ( f1 > 0.0 && f1 < 20.0 ) ? a : 0.1;
b = ( f2 > 0.0 && f2 < 20.0 ) ? b : 0.1;
return 0;
}
float Rectangle::get( float a , float b )
{
cout << "The length is: " << a << endl << "The width is: " << b << endl;
return 0;
}
float Rectangle::area( float a , float b)
{
return a * b;
}
float Rectangle::p( float a , float b )
{
return 2 * a * b;
}
int main()
{
Rectangle R;
R.set(1.4,5.5);
cout << "The area is: " << R.area(a,b)<< endl;
cout << "The perimeter is: " << R.p(a,b) << endl;
R.ger(1.4,5.5);
return 0;
}تحيتي لكمـ
