Previous
Previous Product Image

Easy Notes Of Database Management System unit-3 @Computer Diploma

Original price was: ₹99.99.Current price is: ₹19.99.
Next

Easy Notes Of Object oriented programming unit-2 @Computer Diploma

Original price was: ₹99.99.Current price is: ₹19.99.
Next Product Image

Easy Notes Of Object oriented programming unit-1 @Computer Diploma

Original price was: ₹99.99.Current price is: ₹19.99.

Unit – I Principles of Object Oriented Programming

1.1 Procedure Oriented Programming (POP) verses Object Oriented Programming (OOP)
1.2 Features of Object Oriented Programming, Examples of Object Oriented languages,
Applications of OOP
1.3 Data types, Type compatibility, Declaration of variable, Dynamic initialization of variable,
Reference variable, Type casting
1.4 Special Operators in C++: Scope resolution operator, Memory management operators,
Manipulators
1.5 Structure of C++ program, Basic Input /Output operators and functions in C++, Simple
C++ Program
1.6 Class & Object: Introduction, Specifying a class, Access specifiers, Defining member
functions: Inside class and Outside class, Creating objects, Memory allocations for objects

Hurry Up!
Add to Wishlist
Add to Wishlist

Description

1.1 Procedure Oriented Programming (POP) vs. Object Oriented Programming (OOP)

 

Feature Procedure Oriented Programming (POP) Object Oriented Programming (OOP)
Paradigm Top-down approach. Focuses on a sequence of instructions. Bottom-up approach. Focuses on data and objects.
Data & Function Data is exposed to the entire program. Functions can operate on any data. Data is hidden and encapsulated within objects. Functions (methods) are associated with specific objects.
Security Less secure due to global data access. More secure due to data hiding and encapsulation.
Reusability Low reusability. Functions often depend on global data, making them hard to reuse. High reusability. Objects can be reused in other programs via inheritance and polymorphism.
Real-World Modeling Poor. It’s difficult to model real-world problems with just functions. Excellent. Objects can represent real-world entities (e.g., a “Car” object).
Examples C, Pascal, FORTRAN C++, Java, Python, C#
<br>

 

1.2 Features of Object Oriented Programming

 

The key features of OOP are:

  • Encapsulation: The bundling of data (attributes) and the methods (functions) that operate on that data into a single unit, an object. It also involves data hiding, restricting direct access to an object’s internal state.
  • Abstraction: Hiding the complex implementation details and showing only the essential features of an object. For example, when you drive a car, you don’t need to know how the engine works, only how to use the steering wheel and pedals.
  • Inheritance: A mechanism where a new class (the derived or child class) inherits properties and behaviors from an existing class (the base or parent class). This promotes code reuse and establishes a hierarchical relationship between classes.
  • Polymorphism: The ability of an object to take on many forms. It allows a single interface to be used for a general class of actions. A simple example is a + operator that can perform both addition on numbers and concatenation on strings. This is often achieved through function overloading and function overriding.

Examples of Object-Oriented Languages: Java, C++, Python, C#, Smalltalk, Ruby.

Applications of OOP:

  • GUI-based applications (e.g., user interfaces for software).
  • Real-time systems.
  • Databases.
  • Operating systems.
  • Simulation and modeling systems.
  • Game development.

 

1.3 Data Types, Variables, and Type Compatibility in C++

 

  • Data Types: Classify the type of data that a variable can hold. C++ has built-in types like int (for integers), float and double (for floating-point numbers), char (for characters), and bool (for boolean values). It also supports user-defined types like classes and structures.
  • Type Compatibility: Refers to whether one data type can be assigned to a variable of another data type without a compilation error. This is often handled by type casting or type conversion.
  • Declaration of Variable: The process of specifying a variable’s name and its data type. Example: int age;. This allocates memory for the variable.
  • Dynamic Initialization of Variable: The initialization of a variable at runtime, where the initial value is determined by a user or a computed expression. Example: float area = length * width;.
  • Reference Variable: An alias or another name for an already existing variable. It’s declared using the ampersand &. Any changes made to the reference variable will affect the original variable. Example: int x = 10; int &ref_x = x;.
  • Type Casting: The process of converting one data type into another.
    • Implicit Type Casting (automatic): Done by the compiler, usually for type promotion (e.g., int to float).
    • Explicit Type Casting (manual): Done by the programmer using a cast operator. Example: (int)3.14;.

 

1.4 Special Operators in C++

 

  • Scope Resolution Operator (::): Used to define a member function outside its class, access a static member of a class, or access a global variable when a local variable with the same name exists.
  • Memory Management Operators:
    • new: Used to dynamically allocate memory at runtime. For example, int *ptr = new int; allocates memory for an integer and returns a pointer to it.
    • delete: Used to deallocate memory previously allocated with new. It’s crucial for preventing memory leaks. For example, delete ptr;.
  • Manipulators: Special functions used with input/output streams to format the output.
    • endl: Inserts a newline character and flushes the output buffer.
    • setw(n): Sets the field width to n for the next output operation.

 

1.5 Structure of a C++ Program & Basic I/O

 

A basic C++ program includes:

  • Header Files: Provide declarations for functions and classes (e.g., <iostream> for input/output).
  • main() function: The entry point of every C++ program.
  • Statements and expressions: The instructions that make up the program logic.

Example of a Simple C++ Program:

C++

#include <iostream>

int main() {
    std::cout << "Hello, World!";
    return 0;
}

Basic Input/Output Operators & Functions:

  • Output Operator (<<): Used with std::cout (console output stream) to send data to the console.
  • Input Operator (>>): Used with std::cin (console input stream) to read data from the keyboard.

 

1.6 Class & Object

 

  • Class: A blueprint or template for creating objects. It defines a new data type with its own attributes (data members) and behaviors (member functions). It’s a logical construct; no memory is allocated when a class is defined.
  • Object: An instance of a class. It’s a real-world entity created from the class blueprint. When an object is created, memory is allocated for it.

Specifying a Class: A class is defined using the class keyword, followed by the class name. The members are enclosed in curly braces.

Access Specifiers: Control the visibility and accessibility of class members.

  • public: Members are accessible from outside the class.
  • private: Members are only accessible from within the class itself. This is a key part of encapsulation and data hiding.
  • protected: Members are accessible within the class and by derived classes.

Defining Member Functions:

  • Inside Class Definition: Functions can be defined directly inside the class declaration. These are automatically considered inline functions.
  • Outside Class Definition: Functions are defined outside the class using the scope resolution operator (::) to link the function definition to the class.

Creating Objects: An object is created by using the class name followed by the object name. Example: Car my_car;.

Memory Allocation for Objects: Memory is allocated for an object only when it’s created. The size of the memory allocated depends on the data members defined within the class. Member functions are stored in a common memory area and are not duplicated for each object. The object itself only holds the memory for its data members.

Keywords of this Topic: class, public, private, protected, this (a pointer to the current object), new, delete.

Reviews

There are no reviews yet.

Be the first to review “Easy Notes Of Object oriented programming unit-1 @Computer Diploma”

Your email address will not be published. Required fields are marked *

Shopping cart

0
image/svg+xml

No products in the cart.

Continue Shopping