الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

Inheritance

مغلق
بدأه Super_emad55 في 23 مارس 2006 · 7 رد · 754 مشاهدة · في لغة C و ++C
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

بسم الله الرحمن الرحيم:

many people ask about Inheritance, actually, it is avery nice property that c++ offer for users.

Inheritance is a mechanism by which one class acquires (inherits) the properties (both data and operations) of another class.

In which we have a parents and a child class.

The class being inherited from is the Base Class (Superclass).

The class that inherits is the Derived Class (Subclass).

The derived class is specialized by adding properties specific to it.

for example if we have this parent class:

class  Time
{      
public:    
       void Set ( int hours, int minutes, int seconds);
   void Increment ();
   void Write ()  const;
   Time ( int initHrs, int initMins, int initSecs);
    // Constructor 
   Time ();      // Default constructor

private:    

   int hrs;           
   int mins;          
   int secs;
};

our child class will be as follows:

#include   “time.h”
enum ZoneType{EST, CST, MST, PST, EDT, CDT, MDT, PDT};

class ExtTime : public Time // Time is the base class
{
public:
    void Set(int hours, int minutes, int seconds, ZoneType  timeZone);	
    void Write ()  const;
    ExtTime ( int  initHrs,  int  initMins,  int  initSecs, ZoneType  initZone); 
    ExtTime ();    
private:    
   ZoneType  zone; // Additional data member
};

رجاء تنسيق الكود

in this example we can see how Inheritance can be used, actually it is used in big programs , where there are always many changes, so in such a big programs we have to minimize the number of setps to change things in our program.

تم تعديل هذه المشاركة بواسطة Asm4all في 23 مارس 2006 في 01:03

ENG. IMAD, Programing is a way of life, It's in the air, we breath It's pumps through our veines, Without it, we soon crumble to dust

#2

شكرا على الموضوع ...

ولو أنه كان من المفترض أن يكون باللغـة العربية الفصحى وليس باللغـة الإنجليزيـة ....

الكثير من زوار المنتدى -للأسف- لن يفهموا ما تقوله

#3

اسف ولكن يصعب علي ترجمة المصطلحات

ENG. IMAD, Programing is a way of life, It's in the air, we breath It's pumps through our veines, Without it, we soon crumble to dust

#4

ابق المصطلحات كما هي وترجم النصّ...

ضع المصطلح بالانجليزي بين أقواس.

وشكرا على الموضوع

#5

اللغه المكتوبه, لغه بسيطه جدا, لو احد حاول ان يفهم, سوف يفهم بسهوله, ما اظن في مشاكل,

على اي حال, إن شاء الله في المواضيع اللاحقه

ENG. IMAD, Programing is a way of life, It's in the air, we breath It's pumps through our veines, Without it, we soon crumble to dust

#6

الف شكر اخي Super_emad55 علي الموضوع والكلام فعلا واضح وسهل في الترجمه

Khaled_Tiger

النجاح الوحيد في الحياة هو أن تستطيع أن تحيا حياتك بالطريقة التي تريدها

يخاطبني السفيه بكل قبح *** فأكره أن أكون له مجيبا

يزيد سفاهة فأزيد حلمــا *** كعود زاده الإحراق طيبا

إذا نطق السفيه فلا تجبه *** فخير من إجابته السكوت

فإن كلَمته فرَجت عنــــه *** وإن خليته كمداً يـمـــوت

#7

تسلم يا اخ khaled_tiger

ENG. IMAD, Programing is a way of life, It's in the air, we breath It's pumps through our veines, Without it, we soon crumble to dust

#8

السلام عليكم يا شباب

مرحبا

كيف ممكن أبعثلكم واشارك معكم في أكواد ++C

شكرا

هذا الموضوع مغلق.

مواضيع مشابهة