1. Student of software engineering at
International Islamic university Islamabad
Pakistan.
Second semester .
Email
shafiqkhuidad@gmail.com
shafiqkhuidad@yahoo.com
shafiqkhuidad@oultook.com
shafiqkhuidad@engineer.com
2. Every language that support three
components are called Object oriented
language
1. Class
2. Object
3. Inheritance
Now question is that why we use OOP?
Answer is simple that just for Reuse ability
,and extension and enhancement .
3. Example of reuse ability is CIN object.
You can create cin like objects using oop
concepts.
Class: class is basically user define data type.
Class //key word
{
Data member;//may be int ,float ,etc or
function
};
By default the access restriction on data member
of classes is private .
We can make data access restriction by using
public keyword .
4. Difference b/w structure and class
By default access specification of data member of
class is private while that of structure is public .
We use class in programming due to the reason that
we solve problems of real world using programming
,and all things in universe lies in classes e.g. human
being lies in classes and each human is object of
human class , each human object has its own
attributes(properties ) and functionalities.
Like human born ,perform its functionalities and die
,the same way object is created ,perform
functionalities and then destroy.
When object is created its attributes get space in
memory .
Every object has its own life cycle.
5. Example of class name student
Class
{
char name;
int id;
float cgpa;
Public :
void getdata()
{
cin>>name>>id>>cgpa;
}
void showdata()
{
cout<<name<<endl<<id<<endl<<cgpa<<endl;
}
};
6. Class :
There are two uses/properties/functionalities of
class
a. Encapsulation of data
b. Data hiding
When we write attributes and functionalities
inside class body that’s called encapsulation.
Data hiding means restriction on data access.
We use three key word
1. Private
2. Public
3. Protected