0% found this document useful (0 votes)
23 views12 pages

Class&objectt ABDULMALIK

The document discusses object oriented programming concepts including classes, objects, abstraction, encapsulation, and inheritance. It provides examples of defining classes and creating objects in C++ code to demonstrate OOP concepts.

Uploaded by

afmis1652
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views12 pages

Class&objectt ABDULMALIK

The document discusses object oriented programming concepts including classes, objects, abstraction, encapsulation, and inheritance. It provides examples of defining classes and creating objects in C++ code to demonstrate OOP concepts.

Uploaded by

afmis1652
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

UNIT1 :

Introduction to Oops
Adjectives of this unit
- What Is Oops ?
- What are class and object ? .
- Syntax of class.
- Syntax of object.
- Example1,example2 and example3.
- What are abstraction ,encapsulation and inheritance ?

T.SUB: Abdulmalik A Alsarori


Oops
 Oops stands for object oriented programming
system
 Oops is a concept that combines both the data
and function that operate on that data into a
single unit called the object.
 Oops is the style to design the programs by
using class and object.
 Oops follows “bottom up” design technique.
Features of the Object Oriented programming

 Emphasis is on doing rather than procedure.


 programs are divided into what are known as objects.
 Data structures are designed such that they characterize
the objects.
 Functions that operate on the data of an object are tied
together in the data structure.
 Data is hidden and can‟t be accessed by external
functions.
 Objects may communicate with each other through
functions.
 New data and functions can be easily added.
 Follows bottom-up approach in program design.
Concepts of oops
 Concepts of oops :
- Class.
- Object.
- Abstraction.
- Encapsulation.
- Inheritance.
- Polymorphism.
Class and object
 Class and object are the two main aspects of
oops.
 Class is a template for objects and an object is
an instance of a class.

Objects Objects
Class Class
Apple Volvo
Banana Toyota
Fruit Car
Mango Hyundai
Class
 Class is a diagram ,prototype and blue print
follows object.
 Class is a user-defined type or data structure
declared with keyword class that has properties
”data” and actions “method ”.
 Syntax of declare a class:
User defined name

class class_name
{
Keyword access specifier : //can be private, public or protected
data members; // variables to be used
member functions( ) //methods to access data members
}; //class name end with a semicolon
Object
 Object is real world entity.
 Object contain
- properties
- task performed .
• Object is instance of class.
• Syntax of creating a object :

ClassName objectName ;
Example 1
# include<iostream>
using namespace std; Object x
class person
{ Ahmed 15

string name; Name Age


int age;
};
int main( )
{ person x;
x.name=„Ahmed‟;
x.age=15;
return 0;
}
Example 2
# include<iostream>
using namespace std;
class person Object x
{
string name; Ahmed 15
int age; Name Age
};
int main( ) Object y
{ person x,y;
Ali 20
x.name=„Ahmed‟;
x.age=15; Name Age
y.name=„Ali‟;
y.age=20;
return 0;
}
Example 3
# include<iostream>
using namespace std;
class person
{
string name;
int age;
void getdata()
{
cout<<”enter name”;
cin>>name;
cout<<”enter age”;
cin>>age;
}
};
Example 3
int main( )
{ person p,s;
p.getdata(); Object p

s.getdata(); Ahmed 15 getdata


return 0;
Name Age function
}

Object s

Ali 20 getdata

Name Age function


Abstraction , encapsulation and inheritance

 Abstraction is showing only essential parts


hiding the implementation details.
 Encapsulation is binding variables and methods
under the single entity.
 Inheritance is the capability of a class to derive
properties and characteristics from another
class .

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy