OOPC Notes (Detailed, Open Book)
Unit 1: Principles of OOP
Programming Paradigms
- Procedural Programming: Focuses on functions.
- Object-Oriented Programming (OOP): Focuses on objects.
Basic Concepts of OOP
- Object: Real-world entity with state and behavior.
- Class: Blueprint for creating objects.
- Encapsulation: Wrapping data and functions.
- Abstraction: Hiding internal details.
- Inheritance: Acquiring properties of another class.
- Polymorphism: One interface, many implementations.
Benefits of OOP
- Reusability: Use existing code.
- Scalability: Easy to expand.
- Maintainability: Easy to update and fix.
- Security: Data hiding.
Applications of OOP
- Software Development
- Games, GUI apps, Web apps, Simulations.
C++ Introduction and History
- C++: Extension of C with OOP features.
- Developed by: Bjarne Stroustrup, 1980s.
Structure of C++ Program
- Preprocessor directives (#include)
- Namespace declaration (using namespace)
- main() function
- Class and function definitions
C++ Basics
- Data Types: int, float, char, double, bool.
- Derived Types: Arrays, Pointers, References.
- Symbolic Constants: #define, const.
- Dynamic Initialization: Runtime initialization.
- Type Modifiers: signed, unsigned, long, short.
- Type Casting: Implicit (automatic), Explicit (manual).
- Operators: Arithmetic, Logical, Relational.
- Control Statements: if, switch, for, while, do-while.
- I/O: cin, cout, get(), put()
Unit 2: Classes and Objects
Class Specification
- Declaration: class ClassName { };
- Data Members: Variables inside a class.
- Member Functions: Functions inside a class.
Member Function Specification
- Inside Class: Defined within class.
- Outside Class: Use :: scope resolution.
Access Specifiers
- private: Accessible within class.
- public: Accessible outside class.
- protected: Accessible in derived classes.
Scope Resolution Operator '::'
- Access member functions defined outside the class.
Object Creation
- Declare object using ClassName objectName;
Function Prototyping and Components
- Declare function before use.
- Components: Return type, name, parameters.
Function Arguments
- Pass by Value: Copy of value passed.
- Pass by Reference: Address passed.
Return by Reference
- Returns a reference to a variable.
Inline Functions
- inline keyword, replaces function call with code.
Default Arguments
- Provide default values in function declaration.
Function Overloading
- Same function name, different parameters.
Unit 3: Constructors and Destructors
Constructor
- Special Function: Same name as class.
- Automatically called when object is created.
- No return type.
Types of Constructors:
- Default Constructor: No parameters.
- Parameterized Constructor: With parameters.
- Copy Constructor: Creates copy of an object.
Destructor
- Special Function: Same name with ~.
- Automatically called when object is destroyed.
- No return type and no parameters.
End of Notes (Detailed Till Constructor and Destructor)