{"id":7254,"date":"2025-01-01T09:00:00","date_gmt":"2025-01-01T04:00:00","guid":{"rendered":"https:\/\/afzalbadshah.com\/?p=7254"},"modified":"2026-03-16T17:52:35","modified_gmt":"2026-03-16T12:52:35","slug":"introduction-to-object-oriented-programming-oop-2","status":"publish","type":"post","link":"https:\/\/afzalbadshah.com\/index.php\/2025\/01\/01\/introduction-to-object-oriented-programming-oop-2\/","title":{"rendered":"Introduction to Object-Oriented Programming (OOP)"},"content":{"rendered":"\n<p>Object-Oriented Programming (OOP), is a way of writing programs by focusing on real-life objects. In the real world, everything we deal with is an object, such as a car, a book, or a student. Each of these objects has certain features and can perform specific actions. In OOP, we try to represent these features as attributes and the actions as functions.<\/p>\n\n\n\n<p>This programming style helps us organize our code in a way that is closer to how we understand things in real life. It makes large programs easier to design, manage, and extend.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Aspect comparison<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Aspect<\/th><th>Procedural Programming<\/th><th>Object-Oriented Programming (OOP)<\/th><\/tr><\/thead><tbody><tr><td>Approach<\/td><td>Top-down<\/td><td>Bottom-up<\/td><\/tr><tr><td>Structure<\/td><td>Program is divided into functions<\/td><td>Program is divided into objects and classes<\/td><\/tr><tr><td>Data &amp; Functions<\/td><td>Data and functions are separate<\/td><td>Data and functions are bundled together in objects<\/td><\/tr><tr><td>Reusability<\/td><td>Limited<\/td><td>High (through inheritance and modularity)<\/td><\/tr><tr><td>Security<\/td><td>Less secure (data is exposed)<\/td><td>More secure (data hidden using encapsulation)<\/td><\/tr><tr><td>Real-world Modeling<\/td><td>Difficult to model real-world scenarios<\/td><td>Easier to model real-world entities and interactions<\/td><\/tr><tr><td>Examples<\/td><td>C, Pascal<\/td><td>Java, C++, Python (with OOP), C#<\/td><\/tr><tr><td>Function Reuse<\/td><td>Uses functions repeatedly<\/td><td>Uses objects and methods repeatedly<\/td><\/tr><tr><td>Code Maintenance<\/td><td>Harder to manage and scale in large programs<\/td><td>Easier to manage due to modular structure<\/td><\/tr><tr><td>Main Focus<\/td><td>Focuses on functions (actions)<\/td><td>Focuses on objects (entities)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">What is OOP?<\/h2>\n\n\n\n<p>Object-oriented programming is a programming model that allows developers to organize and build programs around real-world concepts. In this model, we define objects that contain both data (attributes) and actions (functions or methods).<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"Introduction to Object-Oriented Programming (OOP) in C++ | Complete Beginner Lecture\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/1Wt5K3UnEU0?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>The main concepts of OOP are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Classes<\/li>\n\n\n\n<li>Objects<\/li>\n\n\n\n<li>Attributes<\/li>\n\n\n\n<li>Functions<\/li>\n\n\n\n<li>Encapsulation<\/li>\n\n\n\n<li>Inheritance<\/li>\n\n\n\n<li>Polymorphism<\/li>\n<\/ul>\n\n\n\n<p>Each of these will be explained step-by-step below.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"640\" height=\"360\" src=\"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image.png?resize=640%2C360&#038;ssl=1\" alt=\"\" class=\"wp-image-7255\" srcset=\"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image.png?w=1024&amp;ssl=1 1024w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image.png?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image.png?resize=768%2C432&amp;ssl=1 768w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image.png?resize=480%2C270&amp;ssl=1 480w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Why Use Object-Oriented Programming (OOP)?<\/h2>\n\n\n\n<p><strong>Reusability:<\/strong> Through inheritance, new classes can be created based on existing ones, inheriting their properties and methods. This means you can reuse code from previously developed classes, saving time and effort.<\/p>\n\n\n\n<p><strong>Modularity:<\/strong> OOP breaks down complex problems into smaller, manageable objects. Each object encapsulates its data and behavior, making it easier to understand, modify, and test independently.<\/p>\n\n\n\n<p><strong>Maintainability:<\/strong> Encapsulation helps isolate changes, reducing unintended side effects and making updates safer over time.<\/p>\n\n\n\n<p><strong>Flexibility:<\/strong> Polymorphism allows objects of different classes to be treated uniformly if they share the required interface, increasing adaptability.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Key Concepts in Object-Oriented Programming (OOP)<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"640\" height=\"360\" src=\"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-1.png?resize=640%2C360&#038;ssl=1\" alt=\"\" class=\"wp-image-7256\" srcset=\"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-1.png?w=1024&amp;ssl=1 1024w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-1.png?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-1.png?resize=768%2C432&amp;ssl=1 768w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-1.png?resize=480%2C270&amp;ssl=1 480w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Class<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Class is the template, design or blueprint for creating real-world objects. It defines what attributes and functions an object will have, but it doesn\u2019t store real data itself.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"640\" height=\"360\" src=\"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-2.png?resize=640%2C360&#038;ssl=1\" alt=\"\" class=\"wp-image-7257\" srcset=\"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-2.png?w=1024&amp;ssl=1 1024w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-2.png?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-2.png?resize=768%2C432&amp;ssl=1 768w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-2.png?resize=480%2C270&amp;ssl=1 480w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/figure>\n<\/blockquote>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>Representation of class in OOP<\/strong><\/p>\n<\/blockquote>\n\n\n\n<p>For example, a <code>Student<\/code> class can define:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Attributes like <code>name<\/code>, <code>rollNo<\/code>, and <code>department<\/code><\/li>\n\n\n\n<li>Functions like <code>giveExam()<\/code> and <code>submitAssignment()<\/code><\/li>\n<\/ul>\n\n\n\n<p>You can then create many student objects from this one class.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Object<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>An object is a real instance of a class. It is created using the blueprint defined by the class and stores actual data.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"640\" height=\"360\" src=\"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-3.png?resize=640%2C360&#038;ssl=1\" alt=\"\" class=\"wp-image-7258\" srcset=\"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-3.png?w=1024&amp;ssl=1 1024w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-3.png?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-3.png?resize=768%2C432&amp;ssl=1 768w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-3.png?resize=480%2C270&amp;ssl=1 480w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/figure>\n<\/blockquote>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>Class and its objects in OOP<\/strong><\/p>\n<\/blockquote>\n\n\n\n<p>For example, once you define a <code>Student<\/code> class, you can create:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ C++ example\n#include &lt;string&gt;\n\nclass Student {\npublic:\n    std::string name;\n    void giveExam() {\n        \/\/ ...\n    }\n};\n\nint main() {\n    Student s1;\n    s1.name = \"Ali\";\n    s1.giveExam();\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<p>Here, <code>s1<\/code> is an object of class <code>Student<\/code>. Each object can have different values for the same attributes, like different names or roll numbers.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Attributes<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Attributes are the properties or characteristics of an object (also called data members). They describe what an object has.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"640\" height=\"360\" src=\"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-4.png?resize=640%2C360&#038;ssl=1\" alt=\"\" class=\"wp-image-7259\" srcset=\"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-4.png?w=1024&amp;ssl=1 1024w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-4.png?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-4.png?resize=768%2C432&amp;ssl=1 768w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-4.png?resize=480%2C270&amp;ssl=1 480w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/figure>\n<\/blockquote>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>Object attributes in OOP<\/strong><\/p>\n<\/blockquote>\n\n\n\n<p>Attributes are written inside a class and accessed through objects.<\/p>\n\n\n\n<p>For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ C++ example\n#include &lt;string&gt;\n\nclass Book {\npublic:\n    std::string title;\n    std::string author;\n    int pages;\n};\n<\/code><\/pre>\n\n\n\n<p>Here, <code>title<\/code>, <code>author<\/code>, and <code>pages<\/code> are attributes. Each book object will have its own values for these.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Functions<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Functions (methods) define the actions an object can perform. They are written inside the class and called using the object.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"640\" height=\"360\" src=\"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-5.png?resize=640%2C360&#038;ssl=1\" alt=\"\" class=\"wp-image-7260\" srcset=\"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-5.png?w=1024&amp;ssl=1 1024w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-5.png?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-5.png?resize=768%2C432&amp;ssl=1 768w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-5.png?resize=480%2C270&amp;ssl=1 480w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/figure>\n<\/blockquote>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>Function of the object in OOP<\/strong><\/p>\n<\/blockquote>\n\n\n\n<p>For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ C++ example\n#include &lt;iostream&gt;\n\nclass Book {\npublic:\n    void read() {\n        std::cout &lt;&lt; \"Reading the book...\" &lt;&lt; '\\n';\n    }\n\n    void bookmarkPage() {\n        std::cout &lt;&lt; \"Page bookmarked.\" &lt;&lt; '\\n';\n    }\n};\n<\/code><\/pre>\n\n\n\n<p>When we create a <code>Book<\/code> object, it can call these functions to perform tasks.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Encapsulation<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Encapsulation means protecting the internal data of an object by keeping attributes private and accessing them only through special functions (getters and setters).<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"640\" height=\"360\" src=\"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-6.png?resize=640%2C360&#038;ssl=1\" alt=\"\" class=\"wp-image-7261\" srcset=\"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-6.png?w=1024&amp;ssl=1 1024w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-6.png?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-6.png?resize=768%2C432&amp;ssl=1 768w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-6.png?resize=480%2C270&amp;ssl=1 480w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/figure>\n<\/blockquote>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>Encapsulation in OOP<\/strong><\/p>\n<\/blockquote>\n\n\n\n<p>This improves security and keeps the data safe from direct changes.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ C++ example\nclass Student {\nprivate:\n    int marks;\n\npublic:\n    int getMarks() const {\n        return marks;\n    }\n\n    void setMarks(int m) {\n        marks = m;\n    }\n};\n<\/code><\/pre>\n\n\n\n<p>Here, <code>marks<\/code> is private, so it cannot be accessed directly.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Inheritance<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Inheritance means creating a new class based on an existing class. The new class (child) can use everything from the old class (parent) and also add its own features.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"640\" height=\"360\" src=\"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-7.png?resize=640%2C360&#038;ssl=1\" alt=\"\" class=\"wp-image-7262\" srcset=\"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-7.png?w=1024&amp;ssl=1 1024w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-7.png?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-7.png?resize=768%2C432&amp;ssl=1 768w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-7.png?resize=480%2C270&amp;ssl=1 480w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/figure>\n<\/blockquote>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>Inheritance in OOP<\/strong><\/p>\n<\/blockquote>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ C++ example\n#include &lt;iostream&gt;\n\nclass Vehicle {\npublic:\n    void start() {\n        std::cout &lt;&lt; \"Starting...\" &lt;&lt; '\\n';\n    }\n};\n\nclass Car : public Vehicle {\npublic:\n    void playMusic() {\n        std::cout &lt;&lt; \"Playing music...\" &lt;&lt; '\\n';\n    }\n};\n<\/code><\/pre>\n\n\n\n<p><code>Car<\/code> is using <code>start()<\/code> from <code>Vehicle<\/code> and also has its own function <code>playMusic()<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Polymorphism<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Polymorphism means one function behaves differently for different classes. It allows the same function name to do different jobs based on the object.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"640\" height=\"360\" src=\"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-8.png?resize=640%2C360&#038;ssl=1\" alt=\"\" class=\"wp-image-7263\" srcset=\"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-8.png?w=1024&amp;ssl=1 1024w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-8.png?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-8.png?resize=768%2C432&amp;ssl=1 768w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/image-8.png?resize=480%2C270&amp;ssl=1 480w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/figure>\n<\/blockquote>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>Polymorphism in OOP<\/strong><\/p>\n<\/blockquote>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ C++ example\n#include &lt;iostream&gt;\n\nclass Animal {\npublic:\n    virtual void speak() {\n        std::cout &lt;&lt; \"Animal speaks\" &lt;&lt; '\\n';\n    }\n    virtual ~Animal() = default;\n};\n\nclass Dog : public Animal {\npublic:\n    void speak() override {\n        std::cout &lt;&lt; \"Dog barks\" &lt;&lt; '\\n';\n    }\n};\n<\/code><\/pre>\n\n\n\n<p>When we call <code>speak()<\/code>, the result depends on whether the object is an <code>Animal<\/code> or <code>Dog<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Task<\/h2>\n\n\n\n<p>Take a <code>Book<\/code> as an example. Now apply OOP concepts:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Object:<\/strong> A specific book like <code>book1<\/code><\/li>\n\n\n\n<li><strong>Attributes:<\/strong> <code>title<\/code>, <code>author<\/code>, <code>price<\/code><\/li>\n\n\n\n<li><strong>Functions:<\/strong> <code>read()<\/code>, <code>bookmarkPage()<\/code><\/li>\n\n\n\n<li><strong>Encapsulation:<\/strong> Keep <code>price<\/code> private, use methods to get\/set it<\/li>\n\n\n\n<li><strong>Inheritance:<\/strong> Make <code>EBook<\/code> a child class of <code>Book<\/code><\/li>\n\n\n\n<li><strong>Polymorphism:<\/strong> Override <code>read()<\/code> in <code>EBook<\/code> and <code>PrintedBook<\/code><\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-embed is-type-rich is-provider-canva wp-block-embed-canva\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"OOP\" src=\"https:\/\/www.canva.com\/design\/DAGPn6yCRc4\/2WBEAOb9sNj5hYcyJH-t6w\/view?embed&amp;meta\" height=\"360\" width=\"640\" style=\"border: none; border-radius: 8px; width: 640px; height: 360px;\" allowfullscreen=\"allowfullscreen\" allow=\"fullscreen\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Object-Oriented Programming (OOP), is a way of writing programs by focusing on real-life objects. In the real world, everything we deal with is an object, such as a car, a book, or a student. Each of these objects has certain features and can perform specific actions. In OOP, we try to represent these features as attributes and the actions as functions. This programming style helps us organize our code in a way that is closer to how we understand things&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/afzalbadshah.com\/index.php\/2025\/01\/01\/introduction-to-object-oriented-programming-oop-2\/\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":7264,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"enabled":false},"version":2}},"categories":[637],"tags":[704,701,415,717,702,603,608],"class_list":["post-7254","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oop-with-c","tag-c","tag-classes","tag-encapsulation","tag-introduction-to-oop","tag-objects","tag-oop","tag-polymorphism"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/09\/OOP-2.jpg?fit=1920%2C1080&ssl=1","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pf3emP-1T0","jetpack-related-posts":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/posts\/7254","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/comments?post=7254"}],"version-history":[{"count":5,"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/posts\/7254\/revisions"}],"predecessor-version":[{"id":42832,"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/posts\/7254\/revisions\/42832"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/media\/7264"}],"wp:attachment":[{"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/media?parent=7254"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/categories?post=7254"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/tags?post=7254"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}