C++ Inheritance In Hindi – OOPs In Hindi

C++

C++ Inheritance In HindiInheritance OOPs In Hindi – C++ Inheritance Allows Karta Hai Hame Ki Class Define Karo Uske Bad Ham Inherits Kar Sakte Hai All Methods And Properties Yani Dusri Class Ke |

For Example:- Derived Class Kar Sakta Hai Parent Class Ke Properties Ko Istemal |

Read Also :- Classes & Object & Data Members Etc

C++ Inheritance In Hindi

Ek Bar Ek Parent Class Ko Create Karne Ke Bad Ham Parent Class (Base Class ) Ko Ham Derived Class (Sub Class ) Me Istemal kar Sakte Hain And Parent Class Or Derived Class Ke Features To Alag-Alag Honge Hi. Lekin Ham Derived Class Se Parent Class Ke Features Ka Istemal Kar Sakte Hain |

Inheritance OOP Ka Ek Part Hota Hain And Inheritance Mai Ek Se Jyada Classes Hote Hain |

Inheritance In C++ in Hindi Ko Understand Karne Ke Liye Upper Diye Image Ka Example Dekhte Hain

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

Jaise Aap Dekh Sakte Hai Hamne Ek Parent Class (Vehicle) Create Ki Hain Or Vehicle Mai Koi Type Ke Vahical Hote Unke Liye Hamne Derived Class (Car, Bus, Bike ) Alag- Alag Create Ki Or Ab Inhe Derived Class Se Parent Class Ke Features Ka Istemal Kar Sakte Hain.

Read Also :- Python OOPS Concepts

Inheritance Ko 2 Class Dena Jaruri Hota Hain |

  • Base Class(Parent): Base class Ko parent class Bhi Kaha Jata Hain |
  • Derived Class(Child): Derived class Ko sub, Ya child class Bhi Kaha Jata Hain| Derived class Ye Base class Ki properties Ya attributes Ko inherit Karta Hai |

C++ Me Class Ko Inherit Karne Ke Liye : Colon Ka Istemal Kiya Jata Hai |

Example:

// Base class
class Vehicle {
  public:
    string brand = "Ford";
    void honk() {
      cout << "This Is Honk Method \n" ;
    }
};

// Derived class
class Car: public Vehicle {
  public:
    string model = "Mustang";
};

int main() {
  Car myCar;
  myCar.honk();
  cout << myCar.brand + " " + myCar.model;
  return 0;
}

Aap Program Ko Dekh Sakte Hai, Ki Hamne Ek Base Class Vehicle Create Ki And Us Vehicle Class Ke Under Ek Method honk() Create Kiya Hai, Uske Bad Hamne Ek Derived Class Car: Create Ki Or Use Base Class Vehicle Se Inherit Kiya Hai |

Output:

This Is Honk Method
Ford Mustang

Types Of Inheritance in C++ in Hindi

C++ Mai Inheritance 3 Types Ke Hote Hain | Lekin Jo Hamne Abhi Read Kiya Hain Yah Ek Single Inheritance Hain |

Abhi Tak Keval Single Inheritance Ko Cover Kiya Hain Lekin Next Post Mai Ham Multiple And Multilevel Inheritance Ko Cover Karne Wale Hain |

Friends Mujhe Umeed Hai Ki Aapko C Plus Plus Inheritance In Hindi Ke Bare Mai 100% Jankari Ho Gayi Hogi | Agar Aapko Learn Karne Main Dikkat Aa Rahi Hai To Aap Mere Se Contact Kar Sakte Hai |

Leave a Reply

Your email address will not be published. Required fields are marked *