SlideShare a Scribd company logo
﷽
M.Shahid Zafar
M.Sarmad Shuja
M.Ahsan
Wamiq Ali Zain Abid
WHAT IS CLASS ?
The building block of C++ that leads to Object
Oriented programming is a Class. It is a user
defined data type, which holds its own data
members and member functions, which can be
accessed and used by creating an instance of that
class. A class is like a blueprint for an object.
FOR EXAMPLE
Consider the Class of Cars. There may be many
cars with different names and brand but all of them
will share some common properties like all of them
will have 4 wheels, Speed Limit, Mileage range etc.
So here, Car is the class and wheels, speed limits,
mileage are their properties.
WHAT IS CONSTRUCTOR ?
A constructor is a member function of a class which
initializes objects of a class. In C++, Constructor is
automatically called when object(instance of class)
create. It is special member function of the class.
HOW CONSTRUCTORS ARE DIFFERENT
FROM A NORMAL MEMBER FUNCTION?
• Constructor has same name as the class itself
• Constructors don’t have return type
• A constructor is automatically called when an object
is created.
• If we do not specify a constructor, C++ compiler
generates a default constructor for us (expects no
parameters and has an empty body).
PETROLEUM PUMP
#include <iostream>
using namespace std;
class pump{
private:
int num;
float amount , petrol , diesel , cng ;
public:
void input();
void output();
pump()
{
petrol=117.83;
diesel=132.47;
cng=79.82;
}
};
PROGRAM
void pump::input()
{
cout<<"Press 1 for Petrol :: "<<endl;
cout<<"Press 2 for Diesel :: "<<endl;
cout<<"Press 3 for CNG :: "<<endl;
cin>>num;
}
void pump::output()
{
if(num==1)
{
cout<<"Petrol liter :: "<<petrol<<endl<<"Enter the amount :: ";
cin>>amount;
petrol=amount/petrol;
cout<<"liter :: "<<petrol;
}
}
int main()
{
pump a;
a.input();
a.output();
}
HOSTEL MANAGEMENT
OUT PUT
PROGRAM
#include <iostream>
using namespace std;
class hostel{
private:
int num;
public:
void input();
void output();
};
void hostel::input()
{
cout<<"Enter the student id :: ";
cin>>num;
}
void hostel::output()
{
if(num==1)
{
cout<<"student Name ::ttwamiq"<<endl;
cout<<"Class::tttBSCS"<<endl;
cout<<"Room number ::tt5"<<endl;
cout<<"Institute Name ::tNCBA&E"<<endl;
cout<<"Phone number ::t+92-556248585"<<endl;
cout<<"student Fee ::tt6000 per month"<<endl;
cout<<"Address ttMultan";
}
}
int main()
{
hostel b;
b.input();
b.output();
}
FEE MANAGEMENT
#include <iostream>
using namespace std;
class student{
private:
int num,wamiq,fe,total;
public:
void get_roll();
void show_data();
void fee_data();
void latest_data();
student()
{
wamiq=350000;
}
};
void student::get_roll()
{
cout<<"Enter the student roll number :: ";
cin>>num;
}
void student::show_data()
{
if(num==1)
{
cout<<"NametttWamiq"<<endl<<"Father NamettLiaqat
Ali"<<endl<<"ClasstttBSCS(B)"<<endl<<"Total
Feett"<<wamiq<<endl<<"Installmenttt10000"<<endl;
}
}
void student::fee_data()
{
cout<<"Enter the Fee :: ";
cin>>fe;
}
void student::latest_data()
{
cout<<endl<<endl;
if(num==1)
{
total=wamiq-fe;
cout<<"NametttWamiq"<<endl<<"Father NamettLiaqat
Ali"<<endl<<"ClasstttBSCS(B)"<<endl<<"Total
Feett"<<wamiq<<endl<<"Installmenttt10000"<<endl<<"Remaining
Feett"<<total;
}
}
int main()
{
student a;
a.get_roll();
a.show_data();
a.fee_data();
a.latest_data();
}
MONEY EXCHANGE
#include <iostream>
using namespace std;
class curency
{
private:
float dollar/* for input value */,pound,dinar,euro,pakistan;
public:
void get_data();
void output();
curency(){
pound=0.81;
dinar=0.3;
euro=0.9;
pakistan=161.1;
}
};
void curency::get_data()
{
cout<<"Enter amount in dollars($): ";
cin>>dollar;
}
void curency::output()
{
cout << "$" <<dollar << " = " <<dollar*pakistan<<"ttpakistan"<<endl;
cout << "$" << dollar << " = " << dollar*pound << "ttPounds" << endl;
cout << "$" << dollar << " = " << dollar*dinar << "ttDinar" << endl;
cout << "$" << dollar << " = " << dollar*euro << "ttEuro" << endl;
}
int main()
{
curency b;
b.get_data();
b.output();
}
Thank you
Any Question ?

More Related Content

What's hot

Lecture 3 getting_started_with__c_
Lecture 3 getting_started_with__c_Lecture 3 getting_started_with__c_
Lecture 3 getting_started_with__c_
eShikshak
 
PHP: GraphQL consistency through code generation
PHP: GraphQL consistency through code generationPHP: GraphQL consistency through code generation
PHP: GraphQL consistency through code generation
Alexander Obukhov
 
33rd degree talk: open and automatic coding conventions with walkmod
33rd degree talk: open and automatic coding conventions with walkmod33rd degree talk: open and automatic coding conventions with walkmod
33rd degree talk: open and automatic coding conventions with walkmod
walkmod
 
AngularJS
AngularJSAngularJS
AngularJS
Futada Takashi
 
Constructor & destructor
Constructor & destructorConstructor & destructor
Constructor & destructor
Saharsh Anand
 
Protocol-Oriented Programming in Swift
Protocol-Oriented Programming in SwiftProtocol-Oriented Programming in Swift
Protocol-Oriented Programming in Swift
Oleksandr Stepanov
 
Seasar Conference 2009 White - DI
Seasar Conference 2009 White - DISeasar Conference 2009 White - DI
Seasar Conference 2009 White - DI
都元ダイスケ Miyamoto
 
Protocol in Swift
Protocol in SwiftProtocol in Swift
Protocol in Swift
Yusuke Kita
 
Getting started with typescript
Getting started with typescriptGetting started with typescript
Getting started with typescript
C...L, NESPRESSO, WAFAASSURANCE, SOFRECOM ORANGE
 
Having Fun with Kotlin Android - DILo Surabaya
Having Fun with Kotlin Android - DILo SurabayaHaving Fun with Kotlin Android - DILo Surabaya
Having Fun with Kotlin Android - DILo Surabaya
DILo Surabaya
 

What's hot (10)

Lecture 3 getting_started_with__c_
Lecture 3 getting_started_with__c_Lecture 3 getting_started_with__c_
Lecture 3 getting_started_with__c_
 
PHP: GraphQL consistency through code generation
PHP: GraphQL consistency through code generationPHP: GraphQL consistency through code generation
PHP: GraphQL consistency through code generation
 
33rd degree talk: open and automatic coding conventions with walkmod
33rd degree talk: open and automatic coding conventions with walkmod33rd degree talk: open and automatic coding conventions with walkmod
33rd degree talk: open and automatic coding conventions with walkmod
 
AngularJS
AngularJSAngularJS
AngularJS
 
Constructor & destructor
Constructor & destructorConstructor & destructor
Constructor & destructor
 
Protocol-Oriented Programming in Swift
Protocol-Oriented Programming in SwiftProtocol-Oriented Programming in Swift
Protocol-Oriented Programming in Swift
 
Seasar Conference 2009 White - DI
Seasar Conference 2009 White - DISeasar Conference 2009 White - DI
Seasar Conference 2009 White - DI
 
Protocol in Swift
Protocol in SwiftProtocol in Swift
Protocol in Swift
 
Getting started with typescript
Getting started with typescriptGetting started with typescript
Getting started with typescript
 
Having Fun with Kotlin Android - DILo Surabaya
Having Fun with Kotlin Android - DILo SurabayaHaving Fun with Kotlin Android - DILo Surabaya
Having Fun with Kotlin Android - DILo Surabaya
 

Similar to Object Oriented Programming

OOP and C++Classes
OOP and C++ClassesOOP and C++Classes
OOP and C++Classes
MuhammadHuzaifa981023
 
classes object fgfhdfgfdgfgfgfgfdoop.pptx
classes object  fgfhdfgfdgfgfgfgfdoop.pptxclasses object  fgfhdfgfdgfgfgfgfdoop.pptx
classes object fgfhdfgfdgfgfgfgfdoop.pptx
arjun431527
 
21CSC101T best ppt ever OODP UNIT-2.pptx
21CSC101T best ppt ever OODP UNIT-2.pptx21CSC101T best ppt ever OODP UNIT-2.pptx
21CSC101T best ppt ever OODP UNIT-2.pptx
Anantjain234527
 
Unit4_2.pdf
Unit4_2.pdfUnit4_2.pdf
Unit4_2.pdf
ElakkiyaE8
 
INTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptx
INTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptxINTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptx
INTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptx
DeepasCSE
 
Object-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modulesObject-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modules
Durgesh Singh
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
Keyur Vadodariya
 
Object oriented programming 2
Object oriented programming 2Object oriented programming 2
Object oriented programming 2
Aadil Ansari
 
[OOP - Lec 13,14,15] Constructors / Destructor and its Types
[OOP - Lec 13,14,15] Constructors / Destructor and its Types[OOP - Lec 13,14,15] Constructors / Destructor and its Types
[OOP - Lec 13,14,15] Constructors / Destructor and its Types
Muhammad Hammad Waseem
 
Presentation 1st
Presentation 1stPresentation 1st
Presentation 1st
Connex
 
TypeScript for Java Developers
TypeScript for Java DevelopersTypeScript for Java Developers
TypeScript for Java Developers
Yakov Fain
 
Oops
OopsOops
chapter-9-constructors.pdf
chapter-9-constructors.pdfchapter-9-constructors.pdf
chapter-9-constructors.pdf
study material
 
U19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).pptU19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).ppt
Manivannan837728
 
csharp.docx
csharp.docxcsharp.docx
csharp.docx
LenchoMamudeBaro
 
Typescript language extension of java script
Typescript language extension of java scriptTypescript language extension of java script
Typescript language extension of java script
michaelaaron25322
 
OOPS using C++
OOPS using C++OOPS using C++
OOPS using C++
cpjcollege
 
OOP in C# Classes and Objects.
OOP in C# Classes and Objects.OOP in C# Classes and Objects.
OOP in C# Classes and Objects.
Abid Kohistani
 
Constructors and destructors in C++
Constructors and destructors in  C++Constructors and destructors in  C++
Constructors and destructors in C++
RAJ KUMAR
 
Session 3 - Object oriented programming with Objective-C (part 1)
Session 3 - Object oriented programming with Objective-C (part 1)Session 3 - Object oriented programming with Objective-C (part 1)
Session 3 - Object oriented programming with Objective-C (part 1)
Vu Tran Lam
 

Similar to Object Oriented Programming (20)

OOP and C++Classes
OOP and C++ClassesOOP and C++Classes
OOP and C++Classes
 
classes object fgfhdfgfdgfgfgfgfdoop.pptx
classes object  fgfhdfgfdgfgfgfgfdoop.pptxclasses object  fgfhdfgfdgfgfgfgfdoop.pptx
classes object fgfhdfgfdgfgfgfgfdoop.pptx
 
21CSC101T best ppt ever OODP UNIT-2.pptx
21CSC101T best ppt ever OODP UNIT-2.pptx21CSC101T best ppt ever OODP UNIT-2.pptx
21CSC101T best ppt ever OODP UNIT-2.pptx
 
Unit4_2.pdf
Unit4_2.pdfUnit4_2.pdf
Unit4_2.pdf
 
INTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptx
INTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptxINTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptx
INTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptx
 
Object-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modulesObject-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modules
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
Object oriented programming 2
Object oriented programming 2Object oriented programming 2
Object oriented programming 2
 
[OOP - Lec 13,14,15] Constructors / Destructor and its Types
[OOP - Lec 13,14,15] Constructors / Destructor and its Types[OOP - Lec 13,14,15] Constructors / Destructor and its Types
[OOP - Lec 13,14,15] Constructors / Destructor and its Types
 
Presentation 1st
Presentation 1stPresentation 1st
Presentation 1st
 
TypeScript for Java Developers
TypeScript for Java DevelopersTypeScript for Java Developers
TypeScript for Java Developers
 
Oops
OopsOops
Oops
 
chapter-9-constructors.pdf
chapter-9-constructors.pdfchapter-9-constructors.pdf
chapter-9-constructors.pdf
 
U19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).pptU19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).ppt
 
csharp.docx
csharp.docxcsharp.docx
csharp.docx
 
Typescript language extension of java script
Typescript language extension of java scriptTypescript language extension of java script
Typescript language extension of java script
 
OOPS using C++
OOPS using C++OOPS using C++
OOPS using C++
 
OOP in C# Classes and Objects.
OOP in C# Classes and Objects.OOP in C# Classes and Objects.
OOP in C# Classes and Objects.
 
Constructors and destructors in C++
Constructors and destructors in  C++Constructors and destructors in  C++
Constructors and destructors in C++
 
Session 3 - Object oriented programming with Objective-C (part 1)
Session 3 - Object oriented programming with Objective-C (part 1)Session 3 - Object oriented programming with Objective-C (part 1)
Session 3 - Object oriented programming with Objective-C (part 1)
 

More from Zain Abid

Satellite Communication || Wireless Communication
Satellite Communication || Wireless CommunicationSatellite Communication || Wireless Communication
Satellite Communication || Wireless Communication
Zain Abid
 
Cyber Security
Cyber SecurityCyber Security
Cyber Security
Zain Abid
 
SYNTAX Directed Translation Report || Compiler Construction
SYNTAX Directed Translation Report || Compiler ConstructionSYNTAX Directed Translation Report || Compiler Construction
SYNTAX Directed Translation Report || Compiler Construction
Zain Abid
 
SYNTAX Directed Translation PPT || Compiler Construction
SYNTAX Directed Translation PPT || Compiler Construction SYNTAX Directed Translation PPT || Compiler Construction
SYNTAX Directed Translation PPT || Compiler Construction
Zain Abid
 
Factors Affecting the System Safety || Linux
Factors Affecting the System Safety || LinuxFactors Affecting the System Safety || Linux
Factors Affecting the System Safety || Linux
Zain Abid
 
Laplace Transform || Multi Variable Calculus
Laplace Transform || Multi Variable Calculus Laplace Transform || Multi Variable Calculus
Laplace Transform || Multi Variable Calculus
Zain Abid
 
Sequence and Series Word File || Discrete Structure
Sequence and Series Word File || Discrete StructureSequence and Series Word File || Discrete Structure
Sequence and Series Word File || Discrete Structure
Zain Abid
 
Sequence and Series in Discrete Structure
Sequence and Series in Discrete Structure Sequence and Series in Discrete Structure
Sequence and Series in Discrete Structure
Zain Abid
 
Disadvantages of Social Media
Disadvantages of Social MediaDisadvantages of Social Media
Disadvantages of Social Media
Zain Abid
 
Marketing Plan || Nano Navigation Chip
Marketing Plan || Nano Navigation ChipMarketing Plan || Nano Navigation Chip
Marketing Plan || Nano Navigation Chip
Zain Abid
 
Imam Bukhari life history || امام بخاری کی ذاتی زندگی || Bukhari Sharif
Imam Bukhari life history || امام بخاری کی ذاتی زندگی || Bukhari SharifImam Bukhari life history || امام بخاری کی ذاتی زندگی || Bukhari Sharif
Imam Bukhari life history || امام بخاری کی ذاتی زندگی || Bukhari Sharif
Zain Abid
 

More from Zain Abid (11)

Satellite Communication || Wireless Communication
Satellite Communication || Wireless CommunicationSatellite Communication || Wireless Communication
Satellite Communication || Wireless Communication
 
Cyber Security
Cyber SecurityCyber Security
Cyber Security
 
SYNTAX Directed Translation Report || Compiler Construction
SYNTAX Directed Translation Report || Compiler ConstructionSYNTAX Directed Translation Report || Compiler Construction
SYNTAX Directed Translation Report || Compiler Construction
 
SYNTAX Directed Translation PPT || Compiler Construction
SYNTAX Directed Translation PPT || Compiler Construction SYNTAX Directed Translation PPT || Compiler Construction
SYNTAX Directed Translation PPT || Compiler Construction
 
Factors Affecting the System Safety || Linux
Factors Affecting the System Safety || LinuxFactors Affecting the System Safety || Linux
Factors Affecting the System Safety || Linux
 
Laplace Transform || Multi Variable Calculus
Laplace Transform || Multi Variable Calculus Laplace Transform || Multi Variable Calculus
Laplace Transform || Multi Variable Calculus
 
Sequence and Series Word File || Discrete Structure
Sequence and Series Word File || Discrete StructureSequence and Series Word File || Discrete Structure
Sequence and Series Word File || Discrete Structure
 
Sequence and Series in Discrete Structure
Sequence and Series in Discrete Structure Sequence and Series in Discrete Structure
Sequence and Series in Discrete Structure
 
Disadvantages of Social Media
Disadvantages of Social MediaDisadvantages of Social Media
Disadvantages of Social Media
 
Marketing Plan || Nano Navigation Chip
Marketing Plan || Nano Navigation ChipMarketing Plan || Nano Navigation Chip
Marketing Plan || Nano Navigation Chip
 
Imam Bukhari life history || امام بخاری کی ذاتی زندگی || Bukhari Sharif
Imam Bukhari life history || امام بخاری کی ذاتی زندگی || Bukhari SharifImam Bukhari life history || امام بخاری کی ذاتی زندگی || Bukhari Sharif
Imam Bukhari life history || امام بخاری کی ذاتی زندگی || Bukhari Sharif
 

Recently uploaded

Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR
Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalRBuilding a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR
Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR
Peter Gallagher
 
按照学校原版(UOL文凭证书)利物浦大学毕业证快速办理
按照学校原版(UOL文凭证书)利物浦大学毕业证快速办理按照学校原版(UOL文凭证书)利物浦大学毕业证快速办理
按照学校原版(UOL文凭证书)利物浦大学毕业证快速办理
terpt4iu
 
一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理
一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理
一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理
aozcue
 
LORRAINE ANDREI_LEQUIGAN_GOOGLE CALENDAR
LORRAINE ANDREI_LEQUIGAN_GOOGLE CALENDARLORRAINE ANDREI_LEQUIGAN_GOOGLE CALENDAR
LORRAINE ANDREI_LEQUIGAN_GOOGLE CALENDAR
lorraineandreiamcidl
 
按照学校原版(Westminster文凭证书)威斯敏斯特大学毕业证快速办理
按照学校原版(Westminster文凭证书)威斯敏斯特大学毕业证快速办理按照学校原版(Westminster文凭证书)威斯敏斯特大学毕业证快速办理
按照学校原版(Westminster文凭证书)威斯敏斯特大学毕业证快速办理
yizxn4sx
 
按照学校原版(UVic文凭证书)维多利亚大学毕业证快速办理
按照学校原版(UVic文凭证书)维多利亚大学毕业证快速办理按照学校原版(UVic文凭证书)维多利亚大学毕业证快速办理
按照学校原版(UVic文凭证书)维多利亚大学毕业证快速办理
1jtj7yul
 
按照学校原版(SUT文凭证书)斯威本科技大学毕业证快速办理
按照学校原版(SUT文凭证书)斯威本科技大学毕业证快速办理按照学校原版(SUT文凭证书)斯威本科技大学毕业证快速办理
按照学校原版(SUT文凭证书)斯威本科技大学毕业证快速办理
1jtj7yul
 
一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理
xuqdabu
 
按照学校原版(USD文凭证书)圣地亚哥大学毕业证快速办理
按照学校原版(USD文凭证书)圣地亚哥大学毕业证快速办理按照学校原版(USD文凭证书)圣地亚哥大学毕业证快速办理
按照学校原版(USD文凭证书)圣地亚哥大学毕业证快速办理
snfdnzl7
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
peuce
 
一比一原版(UOL文凭证书)利物浦大学毕业证如何办理
一比一原版(UOL文凭证书)利物浦大学毕业证如何办理一比一原版(UOL文凭证书)利物浦大学毕业证如何办理
一比一原版(UOL文凭证书)利物浦大学毕业证如何办理
eydeofo
 
加急办理美国南加州大学毕业证文凭毕业证原版一模一样
加急办理美国南加州大学毕业证文凭毕业证原版一模一样加急办理美国南加州大学毕业证文凭毕业证原版一模一样
加急办理美国南加州大学毕业证文凭毕业证原版一模一样
u0g33km
 
Why is the AIS 140 standard Mandatory in India?
Why is the AIS 140 standard Mandatory in India?Why is the AIS 140 standard Mandatory in India?
Why is the AIS 140 standard Mandatory in India?
Watsoo Telematics
 
一比一原版(Monash文凭证书)莫纳什大学毕业证如何办理
一比一原版(Monash文凭证书)莫纳什大学毕业证如何办理一比一原版(Monash文凭证书)莫纳什大学毕业证如何办理
一比一原版(Monash文凭证书)莫纳什大学毕业证如何办理
xuqdabu
 
按照学校原版(QU文凭证书)皇后大学毕业证快速办理
按照学校原版(QU文凭证书)皇后大学毕业证快速办理按照学校原版(QU文凭证书)皇后大学毕业证快速办理
按照学校原版(QU文凭证书)皇后大学毕业证快速办理
8db3cz8x
 
一比一原版(KCL文凭证书)伦敦国王学院毕业证如何办理
一比一原版(KCL文凭证书)伦敦国王学院毕业证如何办理一比一原版(KCL文凭证书)伦敦国王学院毕业证如何办理
一比一原版(KCL文凭证书)伦敦国王学院毕业证如何办理
kuehcub
 
一比一原版(UQ文凭证书)昆士兰大学毕业证如何办理
一比一原版(UQ文凭证书)昆士兰大学毕业证如何办理一比一原版(UQ文凭证书)昆士兰大学毕业证如何办理
一比一原版(UQ文凭证书)昆士兰大学毕业证如何办理
xuqdabu
 
按照学校原版(UAL文凭证书)伦敦艺术大学毕业证快速办理
按照学校原版(UAL文凭证书)伦敦艺术大学毕业证快速办理按照学校原版(UAL文凭证书)伦敦艺术大学毕业证快速办理
按照学校原版(UAL文凭证书)伦敦艺术大学毕业证快速办理
yizxn4sx
 
按照学校原版(UST文凭证书)圣托马斯大学毕业证快速办理
按照学校原版(UST文凭证书)圣托马斯大学毕业证快速办理按照学校原版(UST文凭证书)圣托马斯大学毕业证快速办理
按照学校原版(UST文凭证书)圣托马斯大学毕业证快速办理
zpc0z12
 
一比一原版(Greenwich文凭证书)格林威治大学毕业证如何办理
一比一原版(Greenwich文凭证书)格林威治大学毕业证如何办理一比一原版(Greenwich文凭证书)格林威治大学毕业证如何办理
一比一原版(Greenwich文凭证书)格林威治大学毕业证如何办理
byfazef
 

Recently uploaded (20)

Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR
Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalRBuilding a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR
Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR
 
按照学校原版(UOL文凭证书)利物浦大学毕业证快速办理
按照学校原版(UOL文凭证书)利物浦大学毕业证快速办理按照学校原版(UOL文凭证书)利物浦大学毕业证快速办理
按照学校原版(UOL文凭证书)利物浦大学毕业证快速办理
 
一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理
一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理
一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理
 
LORRAINE ANDREI_LEQUIGAN_GOOGLE CALENDAR
LORRAINE ANDREI_LEQUIGAN_GOOGLE CALENDARLORRAINE ANDREI_LEQUIGAN_GOOGLE CALENDAR
LORRAINE ANDREI_LEQUIGAN_GOOGLE CALENDAR
 
按照学校原版(Westminster文凭证书)威斯敏斯特大学毕业证快速办理
按照学校原版(Westminster文凭证书)威斯敏斯特大学毕业证快速办理按照学校原版(Westminster文凭证书)威斯敏斯特大学毕业证快速办理
按照学校原版(Westminster文凭证书)威斯敏斯特大学毕业证快速办理
 
按照学校原版(UVic文凭证书)维多利亚大学毕业证快速办理
按照学校原版(UVic文凭证书)维多利亚大学毕业证快速办理按照学校原版(UVic文凭证书)维多利亚大学毕业证快速办理
按照学校原版(UVic文凭证书)维多利亚大学毕业证快速办理
 
按照学校原版(SUT文凭证书)斯威本科技大学毕业证快速办理
按照学校原版(SUT文凭证书)斯威本科技大学毕业证快速办理按照学校原版(SUT文凭证书)斯威本科技大学毕业证快速办理
按照学校原版(SUT文凭证书)斯威本科技大学毕业证快速办理
 
一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理
 
按照学校原版(USD文凭证书)圣地亚哥大学毕业证快速办理
按照学校原版(USD文凭证书)圣地亚哥大学毕业证快速办理按照学校原版(USD文凭证书)圣地亚哥大学毕业证快速办理
按照学校原版(USD文凭证书)圣地亚哥大学毕业证快速办理
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
 
一比一原版(UOL文凭证书)利物浦大学毕业证如何办理
一比一原版(UOL文凭证书)利物浦大学毕业证如何办理一比一原版(UOL文凭证书)利物浦大学毕业证如何办理
一比一原版(UOL文凭证书)利物浦大学毕业证如何办理
 
加急办理美国南加州大学毕业证文凭毕业证原版一模一样
加急办理美国南加州大学毕业证文凭毕业证原版一模一样加急办理美国南加州大学毕业证文凭毕业证原版一模一样
加急办理美国南加州大学毕业证文凭毕业证原版一模一样
 
Why is the AIS 140 standard Mandatory in India?
Why is the AIS 140 standard Mandatory in India?Why is the AIS 140 standard Mandatory in India?
Why is the AIS 140 standard Mandatory in India?
 
一比一原版(Monash文凭证书)莫纳什大学毕业证如何办理
一比一原版(Monash文凭证书)莫纳什大学毕业证如何办理一比一原版(Monash文凭证书)莫纳什大学毕业证如何办理
一比一原版(Monash文凭证书)莫纳什大学毕业证如何办理
 
按照学校原版(QU文凭证书)皇后大学毕业证快速办理
按照学校原版(QU文凭证书)皇后大学毕业证快速办理按照学校原版(QU文凭证书)皇后大学毕业证快速办理
按照学校原版(QU文凭证书)皇后大学毕业证快速办理
 
一比一原版(KCL文凭证书)伦敦国王学院毕业证如何办理
一比一原版(KCL文凭证书)伦敦国王学院毕业证如何办理一比一原版(KCL文凭证书)伦敦国王学院毕业证如何办理
一比一原版(KCL文凭证书)伦敦国王学院毕业证如何办理
 
一比一原版(UQ文凭证书)昆士兰大学毕业证如何办理
一比一原版(UQ文凭证书)昆士兰大学毕业证如何办理一比一原版(UQ文凭证书)昆士兰大学毕业证如何办理
一比一原版(UQ文凭证书)昆士兰大学毕业证如何办理
 
按照学校原版(UAL文凭证书)伦敦艺术大学毕业证快速办理
按照学校原版(UAL文凭证书)伦敦艺术大学毕业证快速办理按照学校原版(UAL文凭证书)伦敦艺术大学毕业证快速办理
按照学校原版(UAL文凭证书)伦敦艺术大学毕业证快速办理
 
按照学校原版(UST文凭证书)圣托马斯大学毕业证快速办理
按照学校原版(UST文凭证书)圣托马斯大学毕业证快速办理按照学校原版(UST文凭证书)圣托马斯大学毕业证快速办理
按照学校原版(UST文凭证书)圣托马斯大学毕业证快速办理
 
一比一原版(Greenwich文凭证书)格林威治大学毕业证如何办理
一比一原版(Greenwich文凭证书)格林威治大学毕业证如何办理一比一原版(Greenwich文凭证书)格林威治大学毕业证如何办理
一比一原版(Greenwich文凭证书)格林威治大学毕业证如何办理
 

Object Oriented Programming

  • 1.
  • 3. WHAT IS CLASS ? The building block of C++ that leads to Object Oriented programming is a Class. It is a user defined data type, which holds its own data members and member functions, which can be accessed and used by creating an instance of that class. A class is like a blueprint for an object.
  • 4. FOR EXAMPLE Consider the Class of Cars. There may be many cars with different names and brand but all of them will share some common properties like all of them will have 4 wheels, Speed Limit, Mileage range etc. So here, Car is the class and wheels, speed limits, mileage are their properties.
  • 5. WHAT IS CONSTRUCTOR ? A constructor is a member function of a class which initializes objects of a class. In C++, Constructor is automatically called when object(instance of class) create. It is special member function of the class.
  • 6. HOW CONSTRUCTORS ARE DIFFERENT FROM A NORMAL MEMBER FUNCTION? • Constructor has same name as the class itself • Constructors don’t have return type • A constructor is automatically called when an object is created. • If we do not specify a constructor, C++ compiler generates a default constructor for us (expects no parameters and has an empty body).
  • 8. #include <iostream> using namespace std; class pump{ private: int num; float amount , petrol , diesel , cng ; public: void input(); void output(); pump() { petrol=117.83; diesel=132.47; cng=79.82; } }; PROGRAM
  • 9. void pump::input() { cout<<"Press 1 for Petrol :: "<<endl; cout<<"Press 2 for Diesel :: "<<endl; cout<<"Press 3 for CNG :: "<<endl; cin>>num; } void pump::output() { if(num==1) { cout<<"Petrol liter :: "<<petrol<<endl<<"Enter the amount :: "; cin>>amount; petrol=amount/petrol; cout<<"liter :: "<<petrol; } }
  • 13. PROGRAM #include <iostream> using namespace std; class hostel{ private: int num; public: void input(); void output(); };
  • 14. void hostel::input() { cout<<"Enter the student id :: "; cin>>num; } void hostel::output() { if(num==1) { cout<<"student Name ::ttwamiq"<<endl; cout<<"Class::tttBSCS"<<endl; cout<<"Room number ::tt5"<<endl; cout<<"Institute Name ::tNCBA&E"<<endl; cout<<"Phone number ::t+92-556248585"<<endl; cout<<"student Fee ::tt6000 per month"<<endl; cout<<"Address ttMultan"; } }
  • 16. FEE MANAGEMENT #include <iostream> using namespace std; class student{ private: int num,wamiq,fe,total; public: void get_roll(); void show_data(); void fee_data(); void latest_data(); student() { wamiq=350000; } };
  • 17. void student::get_roll() { cout<<"Enter the student roll number :: "; cin>>num; } void student::show_data() { if(num==1) { cout<<"NametttWamiq"<<endl<<"Father NamettLiaqat Ali"<<endl<<"ClasstttBSCS(B)"<<endl<<"Total Feett"<<wamiq<<endl<<"Installmenttt10000"<<endl; } }
  • 18. void student::fee_data() { cout<<"Enter the Fee :: "; cin>>fe; } void student::latest_data() { cout<<endl<<endl; if(num==1) { total=wamiq-fe; cout<<"NametttWamiq"<<endl<<"Father NamettLiaqat Ali"<<endl<<"ClasstttBSCS(B)"<<endl<<"Total Feett"<<wamiq<<endl<<"Installmenttt10000"<<endl<<"Remaining Feett"<<total; } }
  • 20. MONEY EXCHANGE #include <iostream> using namespace std; class curency { private: float dollar/* for input value */,pound,dinar,euro,pakistan; public: void get_data(); void output(); curency(){ pound=0.81; dinar=0.3; euro=0.9; pakistan=161.1; } };
  • 21. void curency::get_data() { cout<<"Enter amount in dollars($): "; cin>>dollar; } void curency::output() { cout << "$" <<dollar << " = " <<dollar*pakistan<<"ttpakistan"<<endl; cout << "$" << dollar << " = " << dollar*pound << "ttPounds" << endl; cout << "$" << dollar << " = " << dollar*dinar << "ttDinar" << endl; cout << "$" << dollar << " = " << dollar*euro << "ttEuro" << endl; }