C++ Polymorphism In Hindi – OOP’s In Hindi

C++
Loading...

C++ Polymorphism In HindiOOP’s In Hindi – Polymorphism Ye Object-Oriented Programming Ka Bahut Hi Accha Feature Hai And Polymorphish Ek Hi Rup Mai Ek Jyada Rup Hona Polymorphish Hota Hain |

Polymorphism Ye Word ‘poly’ or ‘morph’ In Word Se Milkar Bana Hai|

C++ Polymorphism In Hindi

What is Polymorphism in Hindi:  Polymorphism Means Hota Hai Many Forms In Programming Mai And Polymorphism Mai Kuch Function Hote Hai Jinhe Ham Different Types Mai Istemal kar Sakte Hain |

Example of inbuilt polymorphic functions :

#include <iostream>
#include <string>
using namespace std;

int main() {
  string txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  cout << "The length of the txt string is: " << txt.length();
  return 0;
}

Output:

The length of the txt string is: 26

Hamne Provious Chapter Me Dekha Tha Ki Class Ko Kaise Inherit Karte Hai, Agar Aapne Nhi Dekha Hai To Aap Wo Chapter Bhi Dekhle,

Example 2:

#include <iostream>
#include <string>
using namespace std;

// Base class
class Animal {
  public:
    void animalSound() {
      cout << "The animal makes a sound \n" ;
    }
};

// Derived class
class Pig : public Animal {
  public:
    void animalSound() {
      cout << "The pig says: wee wee \n" ;
    }
};

// Derived class
class Dog : public Animal {
  public:
    void animalSound() {
      cout << "The dog says: bow wow \n" ;
    }
};

int main() {
  Animal myAnimal;
  Pig myPig;
  Dog myDog;

  myAnimal.animalSound();
  myPig.animalSound();
  myDog.animalSound();
  return 0;
}

Aap Upper Dekh Sakte Hai, Ki Hamne Base Class Animal Create Kiya Hai Or Uske Under Ek Method animalSound() Create Kiya Hai, Or Fir Hame Derived Class Pig Create Kiya Hai Or Is Class Ko Animal se Inherit Kiya Hai Or Fir Hamne Pig Class Ke Under animalSound() Methods Ko Create Kiya Different Functionality Ke Sath , And Fir Hame Dog : Class Create Kiya Hai Or Hame Animal Se Inherit Kiya Hai, Or Iske Under animalSound() Methods Kiya Hai , Isme Bhi Hamne Different Functionality Di Hai Or Methods Ka Name Sabhi Class Me Ek Hi hai, Aise Hi Ham Ek Methods Ko Bar Bar Call Kar Sakte Hai Different Functionality Ke Sath , Ise Hi ham Polymorphism Kahte Hai |

Output:

The animal makes a sound
The pig says: wee wee
The dog says: bow wow

Yadi Aapne  HTML Full Course  And CSS Full Course And Python Full Course And PHP Full Course Nhi Read Kiya Hai To Aap Vah Bhi Read Kar Sakte Hai |

Leave a Reply

Your email address will not be published.