PDA

View Full Version : کسی میدونه binding چیه؟؟



flamingo
یک شنبه 16 اسفند 1388, 11:50 صبح
سلام
من تو یک کتاب خوندم که

a method of baseclass can be virtual,resulting dynamic binding. this means that the method connected to an object is bound during the executive of the program rather
than its compilation

هر چقدر فکر کردم نتونستم مفهوم این دوتا کلمه رو بفهمم. میشه یه نفر بهم بگه یعنی چی؟؟
ممنون

amin1softco
یک شنبه 16 اسفند 1388, 12:30 عصر
<H3 align=left>What is Binding?


Binding refers to the act of associating an object or a class with its member. If we can call a method fn() on an object o of a class c, we say that the object o is binded with the method fn(). This happens at compile time and is known as static or compile - time binding. The calls to the virtual member functions are resolved during run-time. This mechanism is known as dynamic binding. The most prominent reason why a virtual function will be used is to have a different functionality in the derived class. The difference between a non-virtual member function and a virtual member function is, the non-virtual member functions are resolved at compile time.
</H3>

flamingo
یک شنبه 16 اسفند 1388, 19:01 عصر
سلام
دستت درد نکنه, ولی من میخواستم یه نفر به فارسی یه توضیح مختصر اگر بتونه بده. توی گوگل خودم
قبلا سرچ کرده بودم!! ولی متوجه نشدم چی میگن.
ممنون

amin1softco
یک شنبه 16 اسفند 1388, 19:16 عصر
من درست نمی دونم ولی شاید منظور همین مفهوم باشه
این حالت زمانی رخ میده که شما دوتا کلاس داری که یکیشون از دیگری مشتق شده و در هر دوی این کلاس ها تابعی با نام fn() داری وقتی که این تابع را صدا بزنی فقط تابع کلاس والد عمل می کنه یعنی تابع کلاس مشتق شده مخفی میشه حالا برای اینکه از این عمل جلوگیری کنیم از توابع مجازی استفاده می کنیم یعنی در کلاس پدر تابع fn را به صورت virtual void fn تعریف می کنیم تا این مشکل کار با شاره گر ها بر طرف بشه

البته خواهشاً دوستانی که وارد تر هستند بیاند و توضیح بدند....

مرتضی پیروزی
یک شنبه 16 اسفند 1388, 21:40 عصر
سلام دوست من
لینک زیر جوابتو داره.
http://www.barnamenevis.org/forum/showthread.php?t=127979
موفق باشی