Object Oriented Programming (OOP) Concepts in C++ Notes | Basic Computer Engineering | RGPV BTech First Year

Object Oriented Programming (OOP) Concepts in C++ Notes | Basic Computer Engineering | RGPV BTech First Year


Object Oriented Programming (OOP) Concepts in C++

Software Development рдХреЗ рдХреНрд╖реЗрддреНрд░ рдореЗрдВ Program рдЬреИрд╕реЗ-рдЬреИрд╕реЗ рдмрдбрд╝реЗ рдФрд░ Complex рд╣реЛрддреЗ рдЧрдП, рд╡реИрд╕реЗ-рд╡реИрд╕реЗ Procedural Programming рдХреА рд╕реАрдорд╛рдПрдБ рд╕реНрдкрд╖реНрдЯ рд╣реЛрдиреЗ рд▓рдЧреАрдВред рдЗрдиреНрд╣реАрдВ рд╕рдорд╕реНрдпрд╛рдУрдВ рдХрд╛ рд╕рдорд╛рдзрд╛рди рдХрд░рдиреЗ рдХреЗ рд▓рд┐рдП Object Oriented Programming (OOP) рд╡рд┐рдХрд╕рд┐рдд рдХреА рдЧрдИред OOP рдПрдХ рдРрд╕реА Programming Methodology рд╣реИ рдЬрд┐рд╕рдореЗрдВ Data рддрдерд╛ Functions рдХреЛ рдПрдХ рд╕рд╛рде Objects рдХреЗ рд░реВрдк рдореЗрдВ рд╡реНрдпрд╡рд╕реНрдерд┐рдд рдХрд┐рдпрд╛ рдЬрд╛рддрд╛ рд╣реИред C++ рдкрд╣рд▓реА рд▓реЛрдХрдкреНрд░рд┐рдп Programming Languages рдореЗрдВ рд╕реЗ рдПрдХ рд╣реИ рдЬрд┐рд╕рдиреЗ Object Oriented Programming рдХреЛ рдкреВрд░реНрдг рд░реВрдк рд╕реЗ Support рдХрд┐рдпрд╛ред

рдЖрдЬ Banking Software, Hospital Management System, ERP Software, Mobile Applications, Games, Operating Systems рддрдерд╛ Enterprise Applications рдЬреИрд╕реЗ рд▓рдЧрднрдЧ рд╕рднреА рдмрдбрд╝реЗ Software Object Oriented Programming Concepts рдХрд╛ рдЙрдкрдпреЛрдЧ рдХрд░рддреЗ рд╣реИрдВред


Introduction to Object Oriented Programming

Object Oriented Programming рдПрдХ Programming Paradigm рд╣реИ рдЬрд┐рд╕рдореЗрдВ рдкреВрд░рд╛ Program Objects рдХреЗ рдЖрдзрд╛рд░ рдкрд░ рдмрдирд╛рдпрд╛ рдЬрд╛рддрд╛ рд╣реИред рдкреНрд░рддреНрдпреЗрдХ Object рдХреЗ рдкрд╛рд╕ рдЕрдкрдиреА Properties (Data) рддрдерд╛ Behaviors (Functions) рд╣реЛрддреЗ рд╣реИрдВред OOP рдХрд╛ рдореБрдЦреНрдп рдЙрджреНрджреЗрд╢реНрдп Code Reusability, Security, Maintainability рддрдерд╛ Modularity рдХреЛ рдмрдврд╝рд╛рдирд╛ рд╣реИред

Procedural Programming рдореЗрдВ Program Functions рдХреЗ рдЖрдзрд╛рд░ рдкрд░ рдмрдирд╛рдпрд╛ рдЬрд╛рддрд╛ рд╣реИ рдЬрдмрдХрд┐ Object Oriented Programming рдореЗрдВ Program рд╡рд╛рд╕реНрддрд╡рд┐рдХ рджреБрдирд┐рдпрд╛ (Real World) рдХреА рд╡рд╕реНрддреБрдУрдВ (Objects) рдХреЗ рдЖрдзрд╛рд░ рдкрд░ рд╡рд┐рдХрд╕рд┐рдд рдХрд┐рдпрд╛ рдЬрд╛рддрд╛ рд╣реИред


Definition of Object Oriented Programming

Object Oriented Programming рдРрд╕реА Programming Technique рд╣реИ рдЬрд┐рд╕рдореЗрдВ Data рддрдерд╛ Functions рдХреЛ Objects рдХреЗ рд░реВрдк рдореЗрдВ рд╕рдВрдЧрдард┐рдд рдХрд┐рдпрд╛ рдЬрд╛рддрд╛ рд╣реИ рддрдерд╛ Class рдХреЗ рдорд╛рдзреНрдпрдо рд╕реЗ рдЙрдиреНрд╣реЗрдВ Manage рдХрд┐рдпрд╛ рдЬрд╛рддрд╛ рд╣реИред

Object Oriented Programming = Programming Based on Classes and Objects

Need of Object Oriented Programming

  • Large Software Projects рдХреЛ Manage рдХрд░рдиреЗ рдХреЗ рд▓рд┐рдПред
  • Code Reusability рдмрдврд╝рд╛рдиреЗ рдХреЗ рд▓рд┐рдПред
  • Data Security рдкреНрд░рджрд╛рди рдХрд░рдиреЗ рдХреЗ рд▓рд┐рдПред
  • Real World Problems рдХреЛ Efficient рддрд░реАрдХреЗ рд╕реЗ Solve рдХрд░рдиреЗ рдХреЗ рд▓рд┐рдПред
  • Maintenance рддрдерд╛ Debugging рдЖрд╕рд╛рди рдмрдирд╛рдиреЗ рдХреЗ рд▓рд┐рдПред
  • Team Development рдХреЛ рд╕рд░рд▓ рдмрдирд╛рдиреЗ рдХреЗ рд▓рд┐рдПред

Characteristics of OOP

  • Class Based Programming.
  • Object Based Design.
  • Encapsulation.
  • Inheritance.
  • Polymorphism.
  • Abstraction.
  • Code Reusability.
  • Message Passing.

Advantages of OOP

  • Reusable Code.
  • High Security.
  • Easy Maintenance.
  • Better Program Organization.
  • Modular Development.
  • Easy Testing.
  • Supports Large Applications.

Limitations of OOP

  • Learning Complexity.
  • Higher Memory Consumption.
  • Execution Overhead.
  • Not Suitable for Very Small Programs.

Difference between Procedure Oriented Programming and Object Oriented Programming

Procedure Oriented Programming Object Oriented Programming
Program Based on Functions Program Based on Objects
Less Secure Highly Secure
No Data Hiding Supports Data Hiding
Less Reusable Highly Reusable
Suitable for Small Programs Suitable for Large Applications

Class

Class рдПрдХ User Defined Data Type рдЕрдерд╡рд╛ Blueprint рд╣реЛрддреА рд╣реИ рдЬрд┐рд╕рдХреЗ рдЖрдзрд╛рд░ рдкрд░ Objects рдмрдирд╛рдП рдЬрд╛рддреЗ рд╣реИрдВред Class рдХреЗ рдЕрдВрджрд░ Data Members рддрдерд╛ Member Functions Define рдХрд┐рдП рдЬрд╛рддреЗ рд╣реИрдВред

class Student { public: int roll; void display() { } };

Object

Object Class рдХрд╛ рд╡рд╛рд╕реНрддрд╡рд┐рдХ Instance рд╣реЛрддрд╛ рд╣реИред Memory рдХреЗрд╡рд▓ Object рдмрдирдиреЗ рдкрд░ Allocate рд╣реЛрддреА рд╣реИред

Student s1;

Data Members

Class рдХреЗ рдЕрдВрджрд░ Declare рдХрд┐рдП рдЧрдП Variables рдХреЛ Data Members рдХрд╣рд╛ рдЬрд╛рддрд╛ рд╣реИред рдпреЗ Object рдХрд╛ Data Store рдХрд░рддреЗ рд╣реИрдВред

class Student { public: int rollNo; string name; };

Member Functions

Class рдХреЗ рдЕрдВрджрд░ Declare рдХрд┐рдП рдЧрдП Functions рдХреЛ Member Functions рдХрд╣рд╛ рдЬрд╛рддрд╛ рд╣реИред рдпреЗ Data Members рдкрд░ Operations Perform рдХрд░рддреЗ рд╣реИрдВред

class Student { public: void display() { cout << "Student"; } };

Access Specifiers

Access Specifiers рдпрд╣ рдирд┐рд░реНрдзрд╛рд░рд┐рдд рдХрд░рддреЗ рд╣реИрдВ рдХрд┐ Class рдХреЗ Members рдХреЛ рдХрд╣рд╛рдБ-рдХрд╣рд╛рдБ рд╕реЗ Access рдХрд┐рдпрд╛ рдЬрд╛ рд╕рдХрддрд╛ рд╣реИред

Specifier Description
public Accessible Everywhere
private Accessible Only Inside Class
protected Accessible Inside Class and Derived Class

Encapsulation

Encapsulation рд╡рд╣ рдкреНрд░рдХреНрд░рд┐рдпрд╛ рд╣реИ рдЬрд┐рд╕рдореЗрдВ Data рддрдерд╛ рдЙрд╕рд╕реЗ рд╕рдВрдмрдВрдзрд┐рдд Functions рдХреЛ рдПрдХ рд╣реА Class рдХреЗ рдЕрдВрджрд░ рд░рдЦрд╛ рдЬрд╛рддрд╛ рд╣реИред рд╕рд╛рде рд╣реА Data рдХреЛ Direct Access рд╕реЗ рд╕реБрд░рдХреНрд╖рд┐рдд рд░рдЦрдиреЗ рдХреЗ рд▓рд┐рдП Access Specifiers рдХрд╛ рдЙрдкрдпреЛрдЧ рдХрд┐рдпрд╛ рдЬрд╛рддрд╛ рд╣реИред рдЗрд╕реЗ Data Hiding рднреА рдХрд╣рд╛ рдЬрд╛рддрд╛ рд╣реИред

class Student { private: int marks; public: void setMarks(int m) { marks = m; } };

Abstraction (Introduction)

Abstraction рдХрд╛ рдЕрд░реНрде рдХреЗрд╡рд▓ рдЖрд╡рд╢реНрдпрдХ рдЬрд╛рдирдХрд╛рд░реА (Essential Information) рдХреЛ рджрд┐рдЦрд╛рдирд╛ рддрдерд╛ Internal Implementation рдХреЛ рдЫрд┐рдкрд╛рдирд╛ рд╣реИред рдЗрд╕рд╕реЗ Program рд╕рд░рд▓, рд╕реБрд░рдХреНрд╖рд┐рдд рддрдерд╛ Maintainable рдмрдирддрд╛ рд╣реИред

  • Reduces Complexity.
  • Provides Better Security.
  • Improves Maintainability.
  • Hides Internal Details.

Inheritance (Introduction)

Inheritance OOP рдХрд╛ рдРрд╕рд╛ Concept рд╣реИ рдЬрд┐рд╕рдХреЗ рдорд╛рдзреНрдпрдо рд╕реЗ рдПрдХ рдирдИ Class рдХрд┐рд╕реА Existing Class рдХреА Properties рддрдерд╛ Member Functions рдХреЛ рдкреНрд░рд╛рдкреНрдд рдХрд░ рд╕рдХрддреА рд╣реИред рдЗрд╕рд╕реЗ Code Reusability рдмрдврд╝рддреА рд╣реИред

class Animal { }; class Dog : public Animal { };

Inheritance рдХрд╛ рдЙрдкрдпреЛрдЧ Large Applications рдореЗрдВ Common Features рдХреЛ Reuse рдХрд░рдиреЗ рдХреЗ рд▓рд┐рдП рдХрд┐рдпрд╛ рдЬрд╛рддрд╛ рд╣реИред


Polymorphism (Introduction)

Polymorphism рдХрд╛ рдЕрд░реНрде рд╣реИ "One Interface, Multiple Forms"ред рдЗрд╕рдХреЗ рдорд╛рдзреНрдпрдо рд╕реЗ рдПрдХ рд╣реА Function рдЕрдерд╡рд╛ Object рд╡рд┐рднрд┐рдиреНрди рдкрд░рд┐рд╕реНрдерд┐рддрд┐рдпреЛрдВ рдореЗрдВ рдЕрд▓рдЧ-рдЕрд▓рдЧ рд╡реНрдпрд╡рд╣рд╛рд░ рдХрд░ рд╕рдХрддрд╛ рд╣реИред

  • Compile Time Polymorphism.
  • Run Time Polymorphism.
  • Improves Flexibility.
  • Supports Dynamic Programming.

Message Passing

Object Oriented Programming рдореЗрдВ Objects рдПрдХ-рджреВрд╕рд░реЗ рдХреЗ рд╕рд╛рде Member Functions рдХреЛ Call рдХрд░рдХреЗ Communication рдХрд░рддреЗ рд╣реИрдВред рдЗрд╕ рдкреНрд░рдХреНрд░рд┐рдпрд╛ рдХреЛ Message Passing рдХрд╣рд╛ рдЬрд╛рддрд╛ рд╣реИред

student.display();

Common Errors

  • Incorrect Object Creation.
  • Improper Access Specifier Usage.
  • Direct Access to Private Members.
  • Missing Class Definition.
  • Improper Inheritance Declaration.
  • Confusing Class and Object.

Best Practices

  • Use Meaningful Class Names.
  • Keep Data Members Private.
  • Provide Public Member Functions.
  • Follow Encapsulation Principle.
  • Reuse Code Using Inheritance.
  • Write Modular Classes.

Applications of Object Oriented Programming

  • Banking Management Systems.
  • Hospital Management Software.
  • School and College ERP.
  • Game Development.
  • Desktop Applications.
  • Mobile Applications.
  • Enterprise Software.
  • Database Management Systems.
  • Artificial Intelligence.
  • Operating Systems.

Industrial Importance

рдЖрдЬ рд▓рдЧрднрдЧ рд╕рднреА рдЖрдзреБрдирд┐рдХ Programming Languages рдЬреИрд╕реЗ C++, Java, C#, Python рддрдерд╛ Kotlin Object Oriented Programming Concepts рдХрд╛ рдЙрдкрдпреЛрдЧ рдХрд░рддреА рд╣реИрдВред Enterprise Software, Banking Systems, E-Commerce Platforms, Healthcare Applications, Mobile Apps рддрдерд╛ Cloud Applications рдореЗрдВ OOP рд╕рдмрд╕реЗ рдЕрдзрд┐рдХ рдЙрдкрдпреЛрдЧ рд╣реЛрдиреЗ рд╡рд╛рд▓реА Programming Methodology рд╣реИред OOP рдХреЗ рдХрд╛рд░рдг Software рдЕрдзрд┐рдХ Secure, Reusable, Maintainable рддрдерд╛ Scalable рдмрдирддрд╛ рд╣реИред


Viva Questions

  1. What is Object Oriented Programming?
  2. What is a Class?
  3. What is an Object?
  4. Differentiate Class and Object.
  5. What are Data Members?
  6. What are Member Functions?
  7. Explain Encapsulation.
  8. What is Abstraction?
  9. What is Inheritance?
  10. What is Polymorphism?
  11. Explain Message Passing.
  12. Differentiate POP and OOP.

Exam Oriented Important Questions

  1. Define Object Oriented Programming with suitable examples.
  2. Differentiate Procedure Oriented Programming and Object Oriented Programming.
  3. Explain Class and Object.
  4. Describe Data Members and Member Functions.
  5. Explain Access Specifiers in C++.
  6. Write short notes on Encapsulation, Abstraction, Inheritance and Polymorphism.
  7. Explain Message Passing in OOP.
  8. Discuss the applications and industrial importance of OOP.

Conclusion

Object Oriented Programming рдЖрдзреБрдирд┐рдХ Software Development рдХреА рдЖрдзрд╛рд░рд╢рд┐рд▓рд╛ рд╣реИред Class, Object, Encapsulation, Abstraction, Inheritance рддрдерд╛ Polymorphism рдЬреИрд╕реЗ Concepts Software рдХреЛ рдЕрдзрд┐рдХ Secure, Reusable, Modular рддрдерд╛ Maintainable рдмрдирд╛рддреЗ рд╣реИрдВред C++ рдореЗрдВ OOP рдХреА рдЕрдЪреНрдЫреА рд╕рдордЭ рдкреНрд░рддреНрдпреЗрдХ Computer Engineering Student рдХреЗ рд▓рд┐рдП рдЕрддреНрдпрдВрдд рдЖрд╡рд╢реНрдпрдХ рд╣реИ рдХреНрдпреЛрдВрдХрд┐ рдпрд╣реА Concepts рдЖрдЧреЗ Advanced C++, Java, Python рддрдерд╛ Professional Software Development рдореЗрдВ рд╡реНрдпрд╛рдкрдХ рд░реВрдк рд╕реЗ рдЙрдкрдпреЛрдЧ рдХрд┐рдП рдЬрд╛рддреЗ рд╣реИрдВред

Related Articles

Manipulators in C++ Notes | endl, setw, setprecision, setfill | Basic Computer Engineering | RGPV BTech First Year

0...

Read More тЖТ

Type Conversion in C++ Notes | Basic Computer Engineering | RGPV BTech First Year

Type Co...

Read More тЖТ

Assignment Operator in C++ Notes | Basic Computer Engineering | RGPV BTech First Year

Assignm...

Read More тЖТ

Copy Constructor in C++ Notes | Basic Computer Engineering | RGPV BTech First Year

Copy Co...

Read More тЖТ

this Pointer in C++ Notes | Basic Computer Engineering | RGPV BTech First Year

this Po...

Read More тЖТ