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

PPTX
Classes and objects
PPTX
Constructor and Destructors in C++
PPTX
Tokens in C++
PPTX
Encapsulation C++
PPTX
How java differs from c and c++
PPT
Interface in java By Dheeraj Kumar Singh
PPTX
Destructors
PDF
Operator overloading C++
Classes and objects
Constructor and Destructors in C++
Tokens in C++
Encapsulation C++
How java differs from c and c++
Interface in java By Dheeraj Kumar Singh
Destructors
Operator overloading C++

What's hot (20)

PPTX
Java packages
PDF
Constructor and Destructor
PPTX
Friend function
PPTX
Java Method, Static Block
PPTX
Static Data Members and Member Functions
PPTX
Control structures in c++
PPTX
Functions in c++
PPTX
Java program structure
PPTX
String, string builder, string buffer
PPTX
INHERITANCE IN JAVA.pptx
PPTX
Java package
PPTX
Inheritance in Java
PPTX
Operator overloading
PPTX
Packages in java
PPTX
Interfaces in java
PPT
Inheritance in java
PPTX
this keyword in Java.pptx
PPTX
Access modifiers in java
PPTX
Abstract class in c++
PPTX
Classes,object and methods java
Java packages
Constructor and Destructor
Friend function
Java Method, Static Block
Static Data Members and Member Functions
Control structures in c++
Functions in c++
Java program structure
String, string builder, string buffer
INHERITANCE IN JAVA.pptx
Java package
Inheritance in Java
Operator overloading
Packages in java
Interfaces in java
Inheritance in java
this keyword in Java.pptx
Access modifiers in java
Abstract class in c++
Classes,object and methods java
Ad

Viewers also liked (20)

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

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

PDF
CLASSES and OBJECTS in C++ detailed explanation
PPTX
C++ classes
PPTX
C++ classes
PPT
C++ Classes Tutorials.ppt
PPT
UNIT I (1).ppt
PPT
UNIT I (1).ppt
PPT
C++ classes tutorials
PPT
oops-1
PPT
Unit i
PPT
classandobjectunit2-150824133722-lva1-app6891.ppt
PDF
Lab 4 (1).pdf
PPTX
Classes and objects
PPTX
Classes and objects
PPTX
PPTX
oopusingc.pptx
PPTX
Oop objects_classes
PPTX
week 2 - classes and objects of object ori9ented programming .pptx
PPTX
Concept of Object-Oriented in C++
PPTX
C++ppt. Classs and object, class and object
PPT
Class and object in C++
CLASSES and OBJECTS in C++ detailed explanation
C++ classes
C++ classes
C++ Classes Tutorials.ppt
UNIT I (1).ppt
UNIT I (1).ppt
C++ classes tutorials
oops-1
Unit i
classandobjectunit2-150824133722-lva1-app6891.ppt
Lab 4 (1).pdf
Classes and objects
Classes and objects
oopusingc.pptx
Oop objects_classes
week 2 - classes and objects of object ori9ented programming .pptx
Concept of Object-Oriented in C++
C++ppt. Classs and object, class and object
Class and object in C++

Recently uploaded (20)

PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PDF
PPT on Performance Review to get promotions
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
additive manufacturing of ss316l using mig welding
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPT
Mechanical Engineering MATERIALS Selection
PPTX
Welding lecture in detail for understanding
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
web development for engineering and engineering
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
Geodesy 1.pptx...............................................
CYBER-CRIMES AND SECURITY A guide to understanding
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
UNIT 4 Total Quality Management .pptx
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPT on Performance Review to get promotions
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
Internet of Things (IOT) - A guide to understanding
Operating System & Kernel Study Guide-1 - converted.pdf
Embodied AI: Ushering in the Next Era of Intelligent Systems
additive manufacturing of ss316l using mig welding
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Mechanical Engineering MATERIALS Selection
Welding lecture in detail for understanding
Lecture Notes Electrical Wiring System Components
web development for engineering and engineering
bas. eng. economics group 4 presentation 1.pptx
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Geodesy 1.pptx...............................................

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