0% found this document useful (0 votes)
2 views2 pages

CPP Notes Module3

The document covers Object-Oriented Programming (OOP) paradigms, detailing its core concepts: Encapsulation, Abstraction, Inheritance, and Polymorphism. It provides a C++ implementation example showcasing a base class 'BaseAnimal' and a derived class 'CanisDog' that demonstrates these OOP principles. The example highlights encapsulation of data, method overriding for polymorphism, and the use of inheritance to extend functionality.

Uploaded by

bs910772
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

CPP Notes Module3

The document covers Object-Oriented Programming (OOP) paradigms, detailing its core concepts: Encapsulation, Abstraction, Inheritance, and Polymorphism. It provides a C++ implementation example showcasing a base class 'BaseAnimal' and a derived class 'CanisDog' that demonstrates these OOP principles. The example highlights encapsulation of data, method overriding for polymorphism, and the use of inheritance to extend functionality.

Uploaded by

bs910772
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

C++ Quick Notes — Module 3

Object-Oriented Programming (OOP) Paradigms

1. Core Concepts & The Four Pillars

OOP models programming domains utilizing programmatic abstractions called Classes (blueprints)
instantiated into runnable Objects (instances).

1. Encapsulation: Shielding private data states via protected access control keywords (private, public).

2. Abstraction: Presenting clear public methods while minimizing complex hidden structural mechanics
from consumers.

3. Inheritance: Permitting child structural classes to derive base architectures and fields from generic
parent frames.

4. Polymorphism: Enabling multi-form runtime overrides utilizing virtual method mappings.


2. Complete OOP Blueprint Implementation

#include <iostream>
#include <string>

// Base Class Frame Setup


class BaseAnimal {
private:
std::string internalName; // Encapsulated variable

public:
// Base Constructor
BaseAnimal(std::string nameValue) : internalName(nameValue) {}

// Encapsulated data Getter Method


std::string getName() const { return internalName; }

// Virtual declaration mapped for dynamic Polymorphic bindings


virtual void triggerSound() const {
std::cout << "* Generic default structural audio echo *
";
}
};

// Derived Child Class mapping (Inheritance)


class CanisDog : public BaseAnimal {
public:
// Route constructor setup arguments upstream
CanisDog(std::string dogName) : BaseAnimal(dogName) {}

// Method Override execution (Polymorphism)


void triggerSound() const override {
std::cout << getName() << " structural node registers sound: Woof!
";
}
};

int main() {
CanisDog userPet("Buddy");
[Link](); // Executes polymorphic target output override
return 0;
}

You might also like