Object-oriented-WPS Office
Object-oriented-WPS Office
computer programming model that code that performs a specific task or class. A class is a blueprint for creating
organizes software design around data, operation. Functions allow you to objects, defining their properties (data
or objects, rather than functions and organize code into manageable pieces, members) and behaviors (member
logic. improve code reusability, and promote functions). When you instantiate a class,
modular programming. you create an object of that class type.
OOP advantages: Objects represent real-world entities or
concepts and encapsulate both data and
1. **Modularity**: OOP allows you to functions to operate on that data.
break down your code into smaller, return statement--- is used inside
manageable modules or classes. 2. functions to terminate the function's object--- is an instance of a class. A class
**Reusability**: OOP promotes execution and optionally return a value is a blueprint for creating objects,
reusability through inheritance and back to the caller. defining their properties (data
polymorphism. You can create a base members) and behaviors (member
class with common functionality and functions). When you instantiate a class,
then derive other classes from it, you create an object of that class type.
inheriting those features. 4. Types of function---Standard Functions: Objects represent real-world entities or
**Encapsulation**: OOP encapsulates These are built-in functions provided by concepts and encapsulate both data and
data and methods within objects, the C++ standard library. Examples functions to operate on that data.
restricting access to them from outside include printf(), scanf()etc.
the class. This protects the integrity of differences between classes and
the data and prevents unauthorized Inline Functions: Inline functions are structures:1. **Default Member
access, enhancing security and reducing functions that are expanded in-line at Access**:
errors.5. **Abstraction**: OOP enables the point of call, rather than being
you to model real-world entities using executed through a function call - In a class, members are private by
abstract data types and operations. By mechanism. default, meaning they can only be
hiding the implementation details and accessed within the class.
Recursive Functions: Recursive functions
focusing on essential features, you can
are functions that call themselves either - In a structure, members are public by
create more intuitive and maintainable
directly or indirectly. default, meaning they can be accessed
code.6. **Polymorphism**: OOP
supports polymorphism, allowing from outside the structure without
user-defined function:in C++ is a custom restrictions.
objects of different classes to be treated
function created by the programmer to
as objects of a common superclass. This
perform a specific task. 2. **Inheritance**:
promotes code flexibility and facilitates
dynamic behavior based on the actual Overloaded function - Classes support inheritance, allowing
type of the object at runtime.
one class to inherit properties and
An overloaded function in C++ refers to behaviors from another class.
Operator overloading---is a feature in a function that has the same name as
many object-oriented programming another function in the same scope but - Structures do not support
languages that allows you to redefine with different parameter lists. This inheritance directly.
the behavior of operators (such as +, -, allows multiple functions with the same
*, /, etc.) for user-defined types or
name to perform different tasks based 3. **Member Functions**:
classes. on the arguments passed to them.
- Classes can have member functions,
basic data types: structure---- is a user-defined data type which are functions that operate on the
that allows you to group together class's data members.
1. Int: Integer type, typically 4 bytes.
variables of different data types under a
single name. It is similar to a class but - Structures can also have member
2. float: Single-precision floating point,
with a few key differences, such as functions in C++, but they were not
usually 4 bytes.
default access level being public for supported in earlier versions of C++.
3.double: Double-precision floating members in a struct whereas it's private
for members in a class by default. 4. **Typical Use Cases**:
point, usually 8 bytes.