If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.
OOP Object Oriented Programing का ही sort form है। PHP , Java , JavaScript की तरह ही C++ भी OOP Concept को support करती है।
OOP (Object Oriented Programing) Classes और Objects पर based एक Programming Paradigm / Approach है। Simple भाषा में कहें तो OOP (Object Oriented Programing) Real World Entity/Object को Programming में represent करने का method / way है।
Real World Entity को ही Programing में Class / Object द्वारा represent किया जाता है। Entity की कुछ Properties या Behavior होता है जिसे Programing में Class variables & methods से represent किया जाता है।
अभी तक आपने जो भी पढ़ा और examples देखे वो सभी procedural programming थी , जिसमे है functions का use करके data पर operations perform करते थे। जबकि object-oriented programming में data को Object / Class के through define और process किया जाता है।
OOP की help से हम DRY (don't repeat yourself) को follow कर पाते हैं , जिससे code को easily maintain, modify और debug कर सकते हैं।
जैसा कि हम जानते हैं कि C ++, C language का ही updated version है। जहाँ C एक Procedure Oriented Programming (POP) है , यह OOP concept support नहीं करती है। जबकि C++ OOP & POP दोनों programming concept support करती है , इसलिए C++ pure OOPs language नहीं है।
Object Oriented Programming के कुछ important principle इस प्रकार है -
किसी class को या Class की properties / behavior को extend करना Inheritance कहते हैं। जिस class को extend किया गया है उसे Parent Class , जिस class के द्वारा extend किया गया है उसे Child Class कहते हैं।
Extend करने पर Child Class में लगभग बो सभी properties / methods होंगे जो Parent Class में हैं।
हालाँकि Parent Class में यह define किया जा सकता है कि कौन सी properties या methods को Child Class access कर सकती है, और कौन से नहीं।
data members को single Object में bind करना ही encapsulation कहलाता है। Encapsulation class में defined variables & methods को protect करने की protection mechanism होती है। encapsulation mechanism की help से हम data members पर अपनी need के according access restrictions define करते हैं , जिससे data को बाहर से access नहीं किया जा सके ।
किसी भी class के लिए internal implementation details को hide करना & सिर्फ Operational process show करना ही Abstraction कहते हैं। abstraction, data Encapsulation से ही implement किया जाता है। abstraction end-user को केवल वही information show करता है जिसको उसकी जरुरत है और implementation details जो hide कर देता है।
simple भाषा में समझें तो किसी single task को different-different way /methods से perform करना ही Polymorphism कहते हैं। Basically Polymorphism दो शव्दों से मिलकर बना है , Poly(Many) & morph (Forms). यह दो type की होती है -
Parent class में define किया गया method Child Class में भी define करना ही Method Overriding कहलाता है। Basically ये scenario Inheritance के साथ perform किया जाता है।
हालाँकि इन सभी concepts के बारे में आप आगे details में examples के साथ पढ़ेंगे , फिलहाल अभी आपको OOPs Concepts का overview दिया है ताकि चीजों को अच्छी तरह से समझ पाएं।
Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)
Get connected with me. :) LinkedIn Twitter Instagram Facebook