Oops Unit 1 Notes
Oops Unit 1 Notes
HI COLLEGE
SYLLABUS
UNIT - 1
HI COLLEGE
OBJECT ORIENTED PARADIG:
Procedural vs. Object-Oriented Development
Class:
A class is a data-type that has its own members i.e. data members and member
functions. It is the blueprint for an object in object oriented programming
language. It is the basic building block of object oriented programming in C++.
The members of a class are accessed in the programming language by creating
an instance of the class.
Encapsulation:
In object oriented programming, encapsulation is the concept of wrapping
together of data and information in a single unit. A formal definition of
encapsulation would be: encapsulation is binding together the data and
related function that can manipulate the data.
Abstraction
Data abstraction or Data Hiding is the concept of hiding data and showing only
relevant data to the final user. It is also an important part object oriented
programing
Polymorphism
The name defines polymorphism is multiple forms. which means
polymorphism is the ability of object oriented programming to do some work
using multiple forms. The behavior of the method is dependent on the type or
the situation in which the method is called.
In C++ programming language, polymorphism is achieved using two ways. They
are operator overloading and function overloading
Inheritance
it is the capability of a class to inherit or derive properties or characteristics
other class. Inheritance is very important and object oriented program as it
allows reusability i.e. using a method defined in another class by using
inheritance. The class that derives properties from other class is known as child
class or subclass and the class from which the properties are inherited is base
class or parent class.
Message passing
OOP is a mechanism for objects to communicate and interact with each other
by sending messages. It involves invoking methods on objects, which can lead
to the exchange of information, execution of a specific behaviour, or
modification of an object's state
Applications:
Client-Server Systems: Object-oriented client-server systems provide the IT
infrastructure, creating Object-Oriented Client-Server Internet (OCSI)
applications.
Benefits:
1.Modularity: OOP allows you to break down complex problems into smaller,
manageable modules (objects).
For example
Integer literals: Examples include 42, -10, and 0xFF (hexadecimal).
Floating-point literals: Examples include 3.14, -0.5, and 1.0e-5.
Character literals: Represented within single quotes, such as 'A', 'b', or '%'.
String literals: Represented within double quotes, such as "Hello", "World", or
"OpenAI".
Bitwise Operators: & (bitwise AND), | (bitwise OR), ^ (bitwise XOR), ~ (bitwise
NOT), << (left shift), >> (right shift).
REFERENCE VARIABLE,
A reference variable in C++ is an alias or alternative name for an existing
variable. It allows you to refer to the same memory location as the original
variable, providing an alternative way to access and manipulate its value.
FUNCTIONS :
In C++, functions are blocks of code that perform specific tasks or operations.
They allow you to organize your code into reusable and modular units, making
it easier to manage and maintain.
DEFAULT ARGUMENTS,
In C++, default arguments allow you to specify default values for function
parameters. When a function is called, if an argument is not provided for a
parameter with a default value, the default value is used instead.
REFERENCES:
A reference is an alias or an alternative name for an existing variable.
It provides a way to access and manipulate the original variable directly.
Once a reference is initialized, it cannot be changed to refer to a different
variable.
References are often used as function parameters to avoid making copies of
large objects.
They are declared using the & symbol after the variable type.
TYPE CONVERSION,
Type conversion, also known as type casting, is the process of converting a
value from one data type to another in a programming language. It allows
you to change the interpretation or representation of a value to suit a
specific context or operation.
FACTORIAL OF NUMBER
FIBONACCI SERIES
New Operator:
The new operator is used to dynamically allocate memory for a single object. It
returns a pointer to the allocated memory.
pointer_variable = new data_type
This statement dynamically allocates memory for an integer array of size 5 and
assigns the address of the allocated memory to the arr pointer.
To deallocate memory for an array, you need to use the delete[] operator:
delete[] arr;
It's important to note that when using dynamic memory allocation, you are
responsible for managing the allocated memory. Always remember to
deallocate the memory using delete or delete[] when you are done using it to
avoid memory leaks.