المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : ممكن تساعدوني في محاولاتي بالكود لحساب المساحه


eshrag.net
07-17-2010, 04:24 PM
<div>السلام عليكم انا عندي سؤال c++
وانا حليته لكن بضل يعطيني ايرور ومو عارفه اكمله للاخر لكن انا بعطيكم محاولاتي وارجوكم تساعدوني الماده هي هيكلة البيانات

هذا السؤال

Define a class Circle that has the data member radius and the functions
• Constructor: take appositive number and set to the radius.
• Get_radius: returns the value of the radius.
• Set_radius: take a number and assign it to the radius.
• Area: compute and return the circle area using the formula
Area = radius * radius * 3.14

Define another class Cylinder that inherit class Circle and has the data members
• height
• diameter: 2 Base radius
The member functions:
• Constructor: take appositive number and set to the height, determine the diameter value.
• Volume: compute and return the Cylinder volume by the formula
Volume= Base Area * height
• Area: compute the cylinder area by using the formula
Area= 2 * Base Area = 3.14 * diameter * heights

In the program.cs class create object of type Circle and another one of type Cylinder and test their functionality




وهذه هي محاولاتي

هذا ال header
كود:
class cir
{
private :
double r;

public:
cir ();
void computearea ( double );
void set_raduis(double);
void get raduis(double&)const;
void printarea ();



};

وهذا implimentation
<div style="margin:20px; margin-top:5px"> كود:
void cir::set_raduis(double raduis )
{
cin>>"please enter the raduis";
if ( raduis >=0)
raduis =r;
else
r = 0;

}

void cir::get_raduis(double& raduis)
{
raduis = r;


}
void cir::printarea()
{
if (r>=0)
cout