Static and Dynamic Binding in C++ in Hindi

Hello दोस्तों! आज हम इस पोस्ट में Static and Dynamic Binding in C++ in Hindi  (डायनामिक और स्टेटिक बाइंडिंग क्या है?) के बारें में पढेंगे और इसके examples को भी देखेंगे. आप इसे पूरा पढ़िए यह आपको आसानी से समझ में आ जायेगा. तो चलिए शुरू करते हैं:-

Static and Dynamic Binding in C++ in Hindi

Binding एक प्रक्रिया है जिसमें identifiers को address में convert किया जाता है. Binding प्रत्येक variable और functions के लिए की जाती है. यह प्रक्रिया run time या compile time में होती है.

Static Binding in C++ in Hindi

  • Static binding को early binding या compile-time polymorphism भी कहते हैं.
  • यह बाइंडिंग compile-time में पूरी होती है.
  • इसमें, function call की matching सही function definition के साथ compile time में होती है.
  • static binding को ऑपरेटर ओवरलोडिंग और फंक्शन ओवरलोडिंग का प्रयोग करके प्राप्त किया जाता है.
  • चूँकि यह बाइंडिंग compile time होती है इसलिए इसमें एक program का execution तेज होता है.

इसका program

#include<iostream>
using namespace std;
class Base {
public:
void display() {
cout<<" In Base class" <<endl;
}
};
class Derived: public Base {
public:
void display() {
cout<<"In Derived class" << endl;
}
};
int main(void) {
Base *base_pointer = new Derived;
base_pointer->display();
return 0;
}

इसका आउटपुट –
In Base Class

Dynamic Binding in C++ in Hindi

  • Dynamic Binding को late binding और runtime polymorphism भी कहते हैं.
  • यह बाइंडिंग runtime में होती है.
  • इसमें, function call की matching सही function definition के साथ runtime में होती है.
  • Dynamic binding को virtual functions का प्रयोग प्राप्त किया जाता है.
  • चूँकि यह runtime में होता है इसलिए इसमें code का execution थोडा slow होता है.
  • डायनामिक बाइंडिंग का मुख्य लाभ यह है कि यह flexible होता है. इसमें केवल एक function अलग-अलग प्रकार के objects को runtime में handle कर सकता है.

इसका program

using namespace std;
class A
{
public:
virtual void display()
{
cout<<"Base";
}
};

class B:public A
{
public:
void display()
{
cout<<"Derived";
}
};
int main()
{
B b;
A *a=&b;
a->display();
return 0;
}

references:- https://www.techiedelight.com/difference-between-static-dynamic-binding-cpp/

static and dynamic in c++ in hindi

निवेदन:- अगर आपके लिए यह article उपयोगी रहा हो तो इसे अपने friends के साथ अवश्य share कीजिये. आपके जो भी questions है उन्हें नीचे comment करके बताइये. अगर आपके दूसरे subjects से related कोई सवाल हो तो उसे भी कमेंट करके बताइए. मैं उसे 1-2 दिन में add कर दूंगा. धन्यवाद.

Leave a Comment