SlideShare a Scribd company logo
DEV BHOOMI GROUP OF 
INSTITUTIONS 
SAHARANPUR 
Name : Saurabh Chauhan 
Class : M.C.A. 1ST (2013-15) 
Roll no : 1358614017 
Topic : Classes and Object. 1 
Sub To : Mr. Rakesh Kumar 
Sub By : Saurabh Chauhan
C++ CLASSES 
& 
OBJECT 
WELCOME :
OUTLINE : 
 Introduction of the class : 
 Characteristics of the class : 
 Format of the class : 
 Define a class type : 
 Implementing class methods : 
 Introduction of an Object : 
 Declaration of an object : 
 Reasons for OOP : 
 Thank you : 
3
INTRODUCTION OF THE CLASS : 
 A class is binding the data and methods. 
 A class is a collection of objects of similar type. 
 A class is an object factory (or producer ) that 
produces similar objects. 
 A class is just like an image and model and can say 
a template. 
 A class does not exists physically because it’s a 
image only in our mind 
 But object exists physically because a object is a 
real world entity i.e. a pen , a chair , a desk , a dog , 
a bike , a car ,a men etc 
 The class and object both are sub method of the 
OOP’s methodology 
4
WHY DO WE NEED TO HAVE CLASS ? 
Characteristics of the class : 
 Structures are public by default and classes are 
private by default. 
 Data more secure in the class. 
 Class reduce the complexity. 
 We can easy and well programming, if we use the 
class in our program . 
5
CLASSES IN C++ 
 A class definition begins with the keyword class. 
 The body of the class is contained within a set of 
braces, { } ; (notice the semi-colon). 
class class_name 
{ 
…. 
…. 
…. 
}; 
Any valid 
identifier 
Class body (data member 
+ methods)
CLASSES IN C++ 
 Within the body, the keywords private: and public: 
specify the access level of the members of the 
class. 
 the default is private. 
 Usually, the data members of a class are declared 
in the private: section of the class and the member 
functions are in public: section.
CLASSES IN C++ 
 Format : 
class class_name 
{ 
private: 
… 
… 
… 
public: 
… 
… 
… 
}; 
private members data 
or variables or 
characteristics 
Public members or methods 
Or behavior
DEFINE A CLASS TYPE 
Header 
class class_name 
{ 
access specifier : 
data ; 
access specifier : 
methods ; 
... 
class Rectangle 
{ 
private: 
int width; 
int length; 
public: 
void set(int w, int l); 
int area(); 
}; 9 
}; 
Body
IMPLEMENTING CLASS METHODS 
 Class implementation: writing the code of 
class methods. 
 There are two ways: 
1. Member functions defined outside class 
 Using Binary scope resolution operator (::) 
 “Ties” member name to class name 
 Uniquely identify functions of particular class 
 Different classes can have member functions with 
same name 
 Format for defining member functions 
ReturnType ClassName::MemberFunctionName( 
){ 
… 
}
IMPLEMENTING CLASS METHODS 
2. Member functions(method) defined inside class 
 Do not need scope resolution 
operator, class name; 
class Circle 
{ 
private: 
double r,ar; 
public: 
void area () 
{ 
cin<<r ; 
ar=r*r*3.14; 
} 
cout<<“n a area of circle -”<<ar; 
}; 
Method 
Defined 
inside 
class
// this is a program of area of circle 
// methods (Defined outside class) 
class Circle 
{ 
private: 
double r,ar; 
public: 
void area(); // mehtod 
}; 
void circle ::area 
{ 
cout<<“n enter the radius of the circle :”; 
cin>>r; 
ar=r*r*3.14; 
cout<<“area of the circle :”<<ar; 
} 
Method 
Defined outside class
13 
OBJECT 
 Object: 
 a variable or an instance of a class 
 Objects may represent any entity ,such as a person , a cat 
a chair , a pen , a place , a bank account , a customer , a table 
of data ,etc. 
 for ex ,bike is an object .its characteristics are :its color 
is black ,Its engine is of 500cc ,Its company is Suzuki .Its 
behavior is to starting the engine ,changing the 
gear ,using the break, etc. 
 Declaration of an Object 
 Initiation of an Object
14 
WHAT IS AN OBJECT? 
OBJECT 
Operations 
Data 
set of methods 
(public member functions) 
internal state 
(values of private data members)
EXAMPLE: A “RABBIT” OBJECT 
 You could (in a game, for example) create an object 
representing a rabbit 
 It would have data: 
 How hungry it is 
 How frightened it is 
 Where it is 
 And methods: 
 eat, hide, run, dig
CONCEPT: CLASSES DESCRIBE OBJECTS 
 Every object belongs to (is an instance of) a class 
 An object may have fields, or variables 
 The class describes those fields 
 An object may have methods 
 The class describes those methods 
 A class is like a template, or cookie cutter
17 
DECLARATION OF AN OBJECT 
class Rectangle 
{ 
private: 
int width; 
int length; 
public: 
void set(int w, int l); 
int area(); 
}; 
main() 
{ 
Rectangle r1; 
Rectangle r2; 
r1.set(5, 8); 
cout<<r1.area()<<endl; 
r2.set(8,10); 
cout<<r2.area()<<endl; 
}
REASONS FOR OOP 
1. Simplify programming 
2. Interfaces 
 Information hiding: 
 Implementation details hidden within classes 
themselves 
3. Software reuse 
 Class objects included as members of 
other classes
THANK YOU

More Related Content

What's hot

classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
HalaiHansaika
 
Constructor and Destructor
Constructor and DestructorConstructor and Destructor
Constructor and DestructorKamal Acharya
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
MOHIT AGARWAL
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
Muhammad Waqas
 
Java Tokens
Java  TokensJava  Tokens
Pure virtual function and abstract class
Pure virtual function and abstract classPure virtual function and abstract class
Pure virtual function and abstract class
Amit Trivedi
 
inheritance c++
inheritance c++inheritance c++
inheritance c++
Muraleedhar Sundararajan
 
Interface in java
Interface in javaInterface in java
Interface in java
PhD Research Scholar
 
[OOP - Lec 01] Introduction to OOP
[OOP - Lec 01] Introduction to OOP[OOP - Lec 01] Introduction to OOP
[OOP - Lec 01] Introduction to OOP
Muhammad Hammad Waseem
 
Object oriented programming with python
Object oriented programming with pythonObject oriented programming with python
Object oriented programming with python
Arslan Arshad
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
rprajat007
 
Encapsulation
EncapsulationEncapsulation
Encapsulation
Burhan Ahmed
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
C# Inheritance
C# InheritanceC# Inheritance
C# Inheritance
Prem Kumar Badri
 
OOP C++
OOP C++OOP C++
OOP C++
Ahmed Farag
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
Pooja Jaiswal
 
Classes and Objects in C#
Classes and Objects in C#Classes and Objects in C#
Classes and Objects in C#
Adeel Rasheed
 

What's hot (20)

classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
 
Constructor and Destructor
Constructor and DestructorConstructor and Destructor
Constructor and Destructor
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
 
Java Tokens
Java  TokensJava  Tokens
Java Tokens
 
Pure virtual function and abstract class
Pure virtual function and abstract classPure virtual function and abstract class
Pure virtual function and abstract class
 
inheritance c++
inheritance c++inheritance c++
inheritance c++
 
Inheritance
InheritanceInheritance
Inheritance
 
Interface in java
Interface in javaInterface in java
Interface in java
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
[OOP - Lec 01] Introduction to OOP
[OOP - Lec 01] Introduction to OOP[OOP - Lec 01] Introduction to OOP
[OOP - Lec 01] Introduction to OOP
 
Object oriented programming with python
Object oriented programming with pythonObject oriented programming with python
Object oriented programming with python
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
 
Encapsulation
EncapsulationEncapsulation
Encapsulation
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
 
C# Inheritance
C# InheritanceC# Inheritance
C# Inheritance
 
OOP C++
OOP C++OOP C++
OOP C++
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 
OOP java
OOP javaOOP java
OOP java
 
Classes and Objects in C#
Classes and Objects in C#Classes and Objects in C#
Classes and Objects in C#
 

Viewers also liked

Class and object in C++ By Pawan Thakur
Class and object in C++ By Pawan ThakurClass and object in C++ By Pawan Thakur
Class and object in C++ By Pawan Thakur
Govt. P.G. College Dharamshala
 
Tugas Aliyah
Tugas AliyahTugas Aliyah
Tugas AliyahAliyahra
 
Fake Ayatollah khomeini's Teachings Are exposed
Fake Ayatollah khomeini's Teachings Are  exposedFake Ayatollah khomeini's Teachings Are  exposed
Fake Ayatollah khomeini's Teachings Are exposed
Prityboykiller
 
Tugas keisha
Tugas  keisha Tugas  keisha
Tugas keisha keishaa17
 
2014 การศึกษาเรียนรู้เรื่อง present-time-อารีรัตน์_การเพียร_5-5
2014 การศึกษาเรียนรู้เรื่อง present-time-อารีรัตน์_การเพียร_5-52014 การศึกษาเรียนรู้เรื่อง present-time-อารีรัตน์_การเพียร_5-5
2014 การศึกษาเรียนรู้เรื่อง present-time-อารีรัตน์_การเพียร_5-5
SlideShare-เยอะเกิน-กฤตยา ศรีริ
 
แบบทดสอบเตรียมความพร้อม ทดสอบก่อนเรียน2588
แบบทดสอบเตรียมความพร้อม ทดสอบก่อนเรียน2588แบบทดสอบเตรียมความพร้อม ทดสอบก่อนเรียน2588
แบบทดสอบเตรียมความพร้อม ทดสอบก่อนเรียน2588
SlideShare-เยอะเกิน-กฤตยา ศรีริ
 
11.แบบทดสอบวัดผลสัมฤทธิ์ทางการเรียนก่อนเรียน40ข้อ 7 pages
11.แบบทดสอบวัดผลสัมฤทธิ์ทางการเรียนก่อนเรียน40ข้อ 7 pages11.แบบทดสอบวัดผลสัมฤทธิ์ทางการเรียนก่อนเรียน40ข้อ 7 pages
11.แบบทดสอบวัดผลสัมฤทธิ์ทางการเรียนก่อนเรียน40ข้อ 7 pages
SlideShare-เยอะเกิน-กฤตยา ศรีริ
 
Tugas keisha
Tugas  keishaTugas  keisha
Tugas keisha
keishaa17
 
Η εφημερίδα της Β΄τάξης
Η εφημερίδα της Β΄τάξης Η εφημερίδα της Β΄τάξης
Η εφημερίδα της Β΄τάξης
Dimitris Kanellopoulos
 
pancasila
pancasilapancasila
pancasila
aqilul ghazir
 
PAI
PAIPAI
Speaking ability – ตามมาฐานที่ชัดเจน2558
Speaking ability – ตามมาฐานที่ชัดเจน2558Speaking ability – ตามมาฐานที่ชัดเจน2558
Speaking ability – ตามมาฐานที่ชัดเจน2558
SlideShare-เยอะเกิน-กฤตยา ศรีริ
 
Fatwa's About Why Shia is Kafir or (Infidels) ? Part-1 From Shia Books
Fatwa's About Why Shia is Kafir or (Infidels) ? Part-1 From Shia BooksFatwa's About Why Shia is Kafir or (Infidels) ? Part-1 From Shia Books
Fatwa's About Why Shia is Kafir or (Infidels) ? Part-1 From Shia Books
Prityboykiller
 
The shias and the belief of the finality of the prophet-hood and insult of th...
The shias and the belief of the finality of the prophet-hood and insult of th...The shias and the belief of the finality of the prophet-hood and insult of th...
The shias and the belief of the finality of the prophet-hood and insult of th...
Prityboykiller
 
To καλοκαίρι και οι διακοπές
To καλοκαίρι και οι διακοπέςTo καλοκαίρι και οι διακοπές
To καλοκαίρι και οι διακοπές
Dimitris Kanellopoulos
 
เฉลย เรียนวันจันทร์ที่20-25 กันยายน2557ข้อสอบภาษาอังกฤษม.5-ปลายภาค255740ข้อ
เฉลย เรียนวันจันทร์ที่20-25 กันยายน2557ข้อสอบภาษาอังกฤษม.5-ปลายภาค255740ข้อเฉลย เรียนวันจันทร์ที่20-25 กันยายน2557ข้อสอบภาษาอังกฤษม.5-ปลายภาค255740ข้อ
เฉลย เรียนวันจันทร์ที่20-25 กันยายน2557ข้อสอบภาษาอังกฤษม.5-ปลายภาค255740ข้อ
SlideShare-เยอะเกิน-กฤตยา ศรีริ
 
Exposed Nawaz Sharif (Pml-n) Part-1
Exposed Nawaz Sharif (Pml-n) Part-1Exposed Nawaz Sharif (Pml-n) Part-1
Exposed Nawaz Sharif (Pml-n) Part-1
Prityboykiller
 

Viewers also liked (20)

098ca session7 c++
098ca session7 c++098ca session7 c++
098ca session7 c++
 
Class and object in C++ By Pawan Thakur
Class and object in C++ By Pawan ThakurClass and object in C++ By Pawan Thakur
Class and object in C++ By Pawan Thakur
 
Tugas Aliyah
Tugas AliyahTugas Aliyah
Tugas Aliyah
 
Fake Ayatollah khomeini's Teachings Are exposed
Fake Ayatollah khomeini's Teachings Are  exposedFake Ayatollah khomeini's Teachings Are  exposed
Fake Ayatollah khomeini's Teachings Are exposed
 
Pendudukan jepang di indonesia
Pendudukan jepang di indonesiaPendudukan jepang di indonesia
Pendudukan jepang di indonesia
 
πεταλούδες
πεταλούδεςπεταλούδες
πεταλούδες
 
Tugas keisha
Tugas  keisha Tugas  keisha
Tugas keisha
 
2014 การศึกษาเรียนรู้เรื่อง present-time-อารีรัตน์_การเพียร_5-5
2014 การศึกษาเรียนรู้เรื่อง present-time-อารีรัตน์_การเพียร_5-52014 การศึกษาเรียนรู้เรื่อง present-time-อารีรัตน์_การเพียร_5-5
2014 การศึกษาเรียนรู้เรื่อง present-time-อารีรัตน์_การเพียร_5-5
 
แบบทดสอบเตรียมความพร้อม ทดสอบก่อนเรียน2588
แบบทดสอบเตรียมความพร้อม ทดสอบก่อนเรียน2588แบบทดสอบเตรียมความพร้อม ทดสอบก่อนเรียน2588
แบบทดสอบเตรียมความพร้อม ทดสอบก่อนเรียน2588
 
11.แบบทดสอบวัดผลสัมฤทธิ์ทางการเรียนก่อนเรียน40ข้อ 7 pages
11.แบบทดสอบวัดผลสัมฤทธิ์ทางการเรียนก่อนเรียน40ข้อ 7 pages11.แบบทดสอบวัดผลสัมฤทธิ์ทางการเรียนก่อนเรียน40ข้อ 7 pages
11.แบบทดสอบวัดผลสัมฤทธิ์ทางการเรียนก่อนเรียน40ข้อ 7 pages
 
Tugas keisha
Tugas  keishaTugas  keisha
Tugas keisha
 
Η εφημερίδα της Β΄τάξης
Η εφημερίδα της Β΄τάξης Η εφημερίδα της Β΄τάξης
Η εφημερίδα της Β΄τάξης
 
pancasila
pancasilapancasila
pancasila
 
PAI
PAIPAI
PAI
 
Speaking ability – ตามมาฐานที่ชัดเจน2558
Speaking ability – ตามมาฐานที่ชัดเจน2558Speaking ability – ตามมาฐานที่ชัดเจน2558
Speaking ability – ตามมาฐานที่ชัดเจน2558
 
Fatwa's About Why Shia is Kafir or (Infidels) ? Part-1 From Shia Books
Fatwa's About Why Shia is Kafir or (Infidels) ? Part-1 From Shia BooksFatwa's About Why Shia is Kafir or (Infidels) ? Part-1 From Shia Books
Fatwa's About Why Shia is Kafir or (Infidels) ? Part-1 From Shia Books
 
The shias and the belief of the finality of the prophet-hood and insult of th...
The shias and the belief of the finality of the prophet-hood and insult of th...The shias and the belief of the finality of the prophet-hood and insult of th...
The shias and the belief of the finality of the prophet-hood and insult of th...
 
To καλοκαίρι και οι διακοπές
To καλοκαίρι και οι διακοπέςTo καλοκαίρι και οι διακοπές
To καλοκαίρι και οι διακοπές
 
เฉลย เรียนวันจันทร์ที่20-25 กันยายน2557ข้อสอบภาษาอังกฤษม.5-ปลายภาค255740ข้อ
เฉลย เรียนวันจันทร์ที่20-25 กันยายน2557ข้อสอบภาษาอังกฤษม.5-ปลายภาค255740ข้อเฉลย เรียนวันจันทร์ที่20-25 กันยายน2557ข้อสอบภาษาอังกฤษม.5-ปลายภาค255740ข้อ
เฉลย เรียนวันจันทร์ที่20-25 กันยายน2557ข้อสอบภาษาอังกฤษม.5-ปลายภาค255740ข้อ
 
Exposed Nawaz Sharif (Pml-n) Part-1
Exposed Nawaz Sharif (Pml-n) Part-1Exposed Nawaz Sharif (Pml-n) Part-1
Exposed Nawaz Sharif (Pml-n) Part-1
 

Similar to C++ And Object in lecture3

Classes and objects
Classes and objectsClasses and objects
Classes and objects
Lovely Professional University
 
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCECLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
Venugopalavarma Raja
 
Lecture 2 (1)
Lecture 2 (1)Lecture 2 (1)
Lecture 2 (1)
zahid khan
 
Classes, objects and methods
Classes, objects and methodsClasses, objects and methods
Classes, objects and methodsfarhan amjad
 
chapter-7-classes-and-objects.pdf
chapter-7-classes-and-objects.pdfchapter-7-classes-and-objects.pdf
chapter-7-classes-and-objects.pdf
study material
 
C++ classes
C++ classesC++ classes
C++ classes
Zahid Tanveer
 
C++ Notes
C++ NotesC++ Notes
Classes in c++ (OOP Presentation)
Classes in c++ (OOP Presentation)Classes in c++ (OOP Presentation)
Classes in c++ (OOP Presentation)Majid Saeed
 
Object Oriented Programming_Lecture 2
Object Oriented Programming_Lecture 2Object Oriented Programming_Lecture 2
Object Oriented Programming_Lecture 2
Mahmoud Alfarra
 
4 Classes & Objects
4 Classes & Objects4 Classes & Objects
4 Classes & Objects
Praveen M Jigajinni
 
classandobjectunit2-150824133722-lva1-app6891.ppt
classandobjectunit2-150824133722-lva1-app6891.pptclassandobjectunit2-150824133722-lva1-app6891.ppt
classandobjectunit2-150824133722-lva1-app6891.ppt
manomkpsg
 
Class and object
Class and objectClass and object
Class and object
prabhat kumar
 
OOPs & C++ UNIT 3
OOPs & C++ UNIT 3OOPs & C++ UNIT 3
OOPs & C++ UNIT 3
SURBHI SAROHA
 
Object and class presentation
Object and class presentationObject and class presentation
Object and class presentation
nafisa rahman
 
class c++
class c++class c++
class c++
vinay chauhan
 
Class and objects
Class and objectsClass and objects
Class and objects
nafisa rahman
 
OBJECT ORIENTED PROGRAMING IN C++
OBJECT ORIENTED PROGRAMING IN C++ OBJECT ORIENTED PROGRAMING IN C++
OBJECT ORIENTED PROGRAMING IN C++
Dev Chauhan
 
Presentation on class and object in Object Oriented programming.
Presentation on class and object in Object Oriented programming.Presentation on class and object in Object Oriented programming.
Presentation on class and object in Object Oriented programming.
Enam Khan
 
Lab 4 (1).pdf
Lab 4 (1).pdfLab 4 (1).pdf
Lab 4 (1).pdf
MohammedAlobaidy16
 

Similar to C++ And Object in lecture3 (20)

Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCECLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
 
Lecture 2 (1)
Lecture 2 (1)Lecture 2 (1)
Lecture 2 (1)
 
Classes
ClassesClasses
Classes
 
Classes, objects and methods
Classes, objects and methodsClasses, objects and methods
Classes, objects and methods
 
chapter-7-classes-and-objects.pdf
chapter-7-classes-and-objects.pdfchapter-7-classes-and-objects.pdf
chapter-7-classes-and-objects.pdf
 
C++ classes
C++ classesC++ classes
C++ classes
 
C++ Notes
C++ NotesC++ Notes
C++ Notes
 
Classes in c++ (OOP Presentation)
Classes in c++ (OOP Presentation)Classes in c++ (OOP Presentation)
Classes in c++ (OOP Presentation)
 
Object Oriented Programming_Lecture 2
Object Oriented Programming_Lecture 2Object Oriented Programming_Lecture 2
Object Oriented Programming_Lecture 2
 
4 Classes & Objects
4 Classes & Objects4 Classes & Objects
4 Classes & Objects
 
classandobjectunit2-150824133722-lva1-app6891.ppt
classandobjectunit2-150824133722-lva1-app6891.pptclassandobjectunit2-150824133722-lva1-app6891.ppt
classandobjectunit2-150824133722-lva1-app6891.ppt
 
Class and object
Class and objectClass and object
Class and object
 
OOPs & C++ UNIT 3
OOPs & C++ UNIT 3OOPs & C++ UNIT 3
OOPs & C++ UNIT 3
 
Object and class presentation
Object and class presentationObject and class presentation
Object and class presentation
 
class c++
class c++class c++
class c++
 
Class and objects
Class and objectsClass and objects
Class and objects
 
OBJECT ORIENTED PROGRAMING IN C++
OBJECT ORIENTED PROGRAMING IN C++ OBJECT ORIENTED PROGRAMING IN C++
OBJECT ORIENTED PROGRAMING IN C++
 
Presentation on class and object in Object Oriented programming.
Presentation on class and object in Object Oriented programming.Presentation on class and object in Object Oriented programming.
Presentation on class and object in Object Oriented programming.
 
Lab 4 (1).pdf
Lab 4 (1).pdfLab 4 (1).pdf
Lab 4 (1).pdf
 

Recently uploaded

在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
Kamal Acharya
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
ShahidSultan24
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
DuvanRamosGarzon1
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
Kamal Acharya
 

Recently uploaded (20)

在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
 

C++ And Object in lecture3

  • 1. DEV BHOOMI GROUP OF INSTITUTIONS SAHARANPUR Name : Saurabh Chauhan Class : M.C.A. 1ST (2013-15) Roll no : 1358614017 Topic : Classes and Object. 1 Sub To : Mr. Rakesh Kumar Sub By : Saurabh Chauhan
  • 2. C++ CLASSES & OBJECT WELCOME :
  • 3. OUTLINE :  Introduction of the class :  Characteristics of the class :  Format of the class :  Define a class type :  Implementing class methods :  Introduction of an Object :  Declaration of an object :  Reasons for OOP :  Thank you : 3
  • 4. INTRODUCTION OF THE CLASS :  A class is binding the data and methods.  A class is a collection of objects of similar type.  A class is an object factory (or producer ) that produces similar objects.  A class is just like an image and model and can say a template.  A class does not exists physically because it’s a image only in our mind  But object exists physically because a object is a real world entity i.e. a pen , a chair , a desk , a dog , a bike , a car ,a men etc  The class and object both are sub method of the OOP’s methodology 4
  • 5. WHY DO WE NEED TO HAVE CLASS ? Characteristics of the class :  Structures are public by default and classes are private by default.  Data more secure in the class.  Class reduce the complexity.  We can easy and well programming, if we use the class in our program . 5
  • 6. CLASSES IN C++  A class definition begins with the keyword class.  The body of the class is contained within a set of braces, { } ; (notice the semi-colon). class class_name { …. …. …. }; Any valid identifier Class body (data member + methods)
  • 7. CLASSES IN C++  Within the body, the keywords private: and public: specify the access level of the members of the class.  the default is private.  Usually, the data members of a class are declared in the private: section of the class and the member functions are in public: section.
  • 8. CLASSES IN C++  Format : class class_name { private: … … … public: … … … }; private members data or variables or characteristics Public members or methods Or behavior
  • 9. DEFINE A CLASS TYPE Header class class_name { access specifier : data ; access specifier : methods ; ... class Rectangle { private: int width; int length; public: void set(int w, int l); int area(); }; 9 }; Body
  • 10. IMPLEMENTING CLASS METHODS  Class implementation: writing the code of class methods.  There are two ways: 1. Member functions defined outside class  Using Binary scope resolution operator (::)  “Ties” member name to class name  Uniquely identify functions of particular class  Different classes can have member functions with same name  Format for defining member functions ReturnType ClassName::MemberFunctionName( ){ … }
  • 11. IMPLEMENTING CLASS METHODS 2. Member functions(method) defined inside class  Do not need scope resolution operator, class name; class Circle { private: double r,ar; public: void area () { cin<<r ; ar=r*r*3.14; } cout<<“n a area of circle -”<<ar; }; Method Defined inside class
  • 12. // this is a program of area of circle // methods (Defined outside class) class Circle { private: double r,ar; public: void area(); // mehtod }; void circle ::area { cout<<“n enter the radius of the circle :”; cin>>r; ar=r*r*3.14; cout<<“area of the circle :”<<ar; } Method Defined outside class
  • 13. 13 OBJECT  Object:  a variable or an instance of a class  Objects may represent any entity ,such as a person , a cat a chair , a pen , a place , a bank account , a customer , a table of data ,etc.  for ex ,bike is an object .its characteristics are :its color is black ,Its engine is of 500cc ,Its company is Suzuki .Its behavior is to starting the engine ,changing the gear ,using the break, etc.  Declaration of an Object  Initiation of an Object
  • 14. 14 WHAT IS AN OBJECT? OBJECT Operations Data set of methods (public member functions) internal state (values of private data members)
  • 15. EXAMPLE: A “RABBIT” OBJECT  You could (in a game, for example) create an object representing a rabbit  It would have data:  How hungry it is  How frightened it is  Where it is  And methods:  eat, hide, run, dig
  • 16. CONCEPT: CLASSES DESCRIBE OBJECTS  Every object belongs to (is an instance of) a class  An object may have fields, or variables  The class describes those fields  An object may have methods  The class describes those methods  A class is like a template, or cookie cutter
  • 17. 17 DECLARATION OF AN OBJECT class Rectangle { private: int width; int length; public: void set(int w, int l); int area(); }; main() { Rectangle r1; Rectangle r2; r1.set(5, 8); cout<<r1.area()<<endl; r2.set(8,10); cout<<r2.area()<<endl; }
  • 18. REASONS FOR OOP 1. Simplify programming 2. Interfaces  Information hiding:  Implementation details hidden within classes themselves 3. Software reuse  Class objects included as members of other classes