In this post you will find complete information about Object Oriented Programming. Here you will find complete information about the Classes, Objects and the Access Specifier.
Object Oriented Programming:
Object-oriented programming is a method of editing where programs
are written on the basis of objects. It is a powerful way to make software. It
is used to analyze and design applications based on materials. It deals with
data and processes that process data as a single entity.
Object-Oriented Programming Features:
Some features
of the targeted program are as follows:
1. Object
Object-oriented programs provide space for object-oriented
programming. An object is a business that contains data and functions.
2. Classes
Classes are
building projects. Object-oriented
programs provide space for classroom building. All properties and functions
of the object are specified in sections.
3. Imitation of the real world
Object-oriented programs are based on real-world models.
Businesses in the real world have a variety of structures and capabilities.
Similarly, objects have data and functions. The data represents the structures
and functions that represent the operation of objects.
4. Reusable
Object-oriented programs allow the developer to reuse data and
code. Uses an asset process to use existing category code to create a new
category.
5. Encryption Information
Object-oriented programs allow the developer to hide important
data from the user. It is done by encapsulation.
6. Polymorphism
Polymorphism
is the ability to behave in many ways.
Objects:
An object represents a business in the
real world as a person, object or idea etc. It is named after him. Item
contains the following:
Features: These are the features of the item.
Tasks: These are things that can be done by
something.
Examples
Some examples
of different types of objects are as follows:
Physical Factors
- Vehicles such as car, bus, truck etc.
- Electrical elements.
Computer Items - User Environment
- Windows
- Menus
- Graphics Items
- Mouse and keyboard
User-defined Data Types
- Time
- Angles
Object Features:
The
properties of an object are known as its properties. Each item has its own
structures. These structures can be used to describe an object. For example,
the properties of an object can be as follows:
- Name
- Age
- Weight
The features
of a car item can be as follows:
- Color
- Price
- Model
- Engine power
The set of symbol values for an object is
called its shape. It means that the condition of an object can be determined by
the value of its properties. The following figure shows the values of the
object properties.
Object Functions:
Active
actions are known as actions or methods. An object can perform different
functions and actions. For example, a Car object can perform the following
functions:
- Get started
- Stop
- Hurry up
- Go back
A set of all
the functions of an object represents the function of an object. It means that
the function of an object can be determined by the list of functions of that
object.
Classes:
A collection of objects with similar
structures and functions is known as a category. A category is used to describe
an object. It is used as a model for building different objects of the same
type. For example, a category person can be used to describe the
characteristics and functions of a person. The Human category can be used to
create various objects such as Ali, Usman, Abdullah etc.
All items of
the Human category will have the same features and functions. However, the
prices for each item may vary. Values are given when an object is created.
Each item of a category is known as an example of its category. For example,
Ali, Usman and Abdullah are three examples of the category of Man. Similarly,
My Book and Your Book can be two scenarios for a Class Book.
Declaring a Class:
The keyword category is used to announce the
category. The section declaration specifies the variables and common functions
in all items of the section. The variables announced in class are called
variants of members or members of the data. Activities announced in the
classroom are known as member
activities.
Syntax:
The class
declaration syntax is as follows:
class identifier
{
body
};
Category: It is the key word used to advertise
a category.
Identifier: It is a category name. The rules for
the class name are the same as the rules for the declaration declaration.
Body: The area enclosed by the earplugs and
earrings) is called a section body. All data members and member functions are
declared within the body. The section announcement always ends with a small
column.
For example
The following
example announces a three-member Class test for data.
Class test
{
int n;
char c;
float x;
};
Access Specifier:
The instructions used to determine the level
of access for class members are known as access
specifier.
The most
important private and public access specifications. Colon used after access
specification when using category.
1. The 'Private' access specifier:
A private access identifier is used to
limit the use of a class member within the classroom. Any category member
announced with a private access specification can only be found within the
category. Cannot be reached outside the category. It is also the default access
adjective. Data members are usually notified by private access specifications.
This is because object data is very sensitive. The private access identifier is
used to protect the data member from direct access from outside the category.
These data members can only be used by activities announced within the
classroom.
For
example
The following
example declares a three-part class trial of data as confidential:
Class test
{
Private:
int n;
char c;
float x;
};
2.
The ' public ' Access Specifier:
The public
access specification is used to allow the user to access a category member
within and outside the class. Any category member advertised for public access specifier can be accessed
from anywhere in the program. Member activities are advertised by definition of
public access. This is because users have access to object functions from
outside the category. The section cannot be used directly if both data members
and member functions are declared confidential.
For example
The following
example introduces a three-day Test class as a secret and two-member activities
as a community.
class Test
{
Private:
int n;
char c;
float x;
public:
void show();
void input();
};


0 Comments