Unit 1 Notes - OOPs with C++ (CAP422J2)
UNIT 1: Introduction to Object-Oriented Programming (15 Hours)
1. Comparison of Procedural Programming and Object-Oriented Programming
(OOP)
| Feature | Procedural Programming | Object-Oriented
Programming |
|------------------------|-------------------------------|-----------------------------|
| Structure | Top-down | Bottom-up |
| Focus | Functions | Objects & Classes |
| Data Access | Globally accessible | Encapsulated |
| Code Reusability | Limited | High |
| Real-world Modeling | Less realistic | More realistic |
2. Benefits of OOP
- Modularity
- Reusability
- Data Hiding
- Scalability
- Real-world Mapping
3. Key OOP Concepts
- Abstraction: Hide unnecessary details.
- Encapsulation: Binding data and methods.
- Inheritance: Code reuse via base and derived classes.
- Polymorphism: One interface, many implementations.
4. Difference between C and C++
| Feature |C | C++ |
|-------------------|------------------------|--------------------------|
| Paradigm | Procedural | Object-Oriented |
| Encapsulation | No | Yes |
| Overloading | Not supported | Supported |
| I/O | scanf/printf | cin/cout |
ELEMENTS OF C++ LANGUAGE
1. Tokens & Identifiers: Smallest units (keywords, constants, etc.)
2. Variables & Constants: Data containers, const/define for constants.
3. Reference Variables: Aliases for existing variables.
4. Data Types: Built-in, Derived, User-defined.
5. Streams: I/O using cin/cout.
6. Operators: Arithmetic, Relational, Logical, Bitwise, etc.
DECISION AND CONTROL STRUCTURES
1. Conditionals: if, if-else, switch
2. Loops: while, do-while, for
3. break/continue: control flow in loops
POINTERS AND STRUCTURES
1. Pointers: Hold memory address of variables.
2. Structures: User-defined grouping of different data types.
Quick Summary:
- Focus on OOP pillars.
- Understand C++ syntax.
- Practice loops, conditionals, pointers, structures.