SlideShare a Scribd company logo
2
Most read
6
Most read
8
Most read
Classes and
Objects in C++
Introduction to C++ Classes
and Objects
The classes are the most important feature
of C++ that leads to Object Oriented
programming. Class is a user defined data
type, which holds its own data members
and member functions, which can be
accessed and used by creating instance
of that class.
The variables inside class definition are
called as data members and the functions
are called member functions.
example:
Class of birds, all birds can fly and they all
have wings and beaks. So here flying is a
behavior and wings and beaks are part of
their characteristics. And there are many
different birds in this class with different
names but they all posses this behavior
and characteristics.
Similarly, class is just a blue print, which
declares and defines characteristics and
behavior, namely data members and
member functions respectively. And all
objects of this class will share these
characteristics and behavior.
Objects of Classes
Objects are instances of class, which
holds the data variables declared in
class and the member functions work
on these class objects. Each object
has different data variables.
Objects are initialized using special class
functions called Constructors.
And whenever the object is out of its
scope, another special class member
function called Destructor is called, to
release the memory reserved by the
object.
Example
class Abc
{
int x;
void display()
{
// some statement
}
};
int main()
{
Abc obj; // Object of class Abc created
}

More Related Content

What's hot (20)

PPTX
Friend function & friend class
Abhishek Wadhwa
 
PPTX
class and objects
Payel Guria
 
PDF
Class and Objects in Java
Spotle.ai
 
PPTX
Inner classes in java
PhD Research Scholar
 
PDF
Friend function in c++
University of Madras
 
PPTX
Array of objects.pptx
RAGAVIC2
 
PPTX
Oop c++class(final).ppt
Alok Kumar
 
PPTX
Inner class
Guna Sekaran
 
PPT
friend function(c++)
Ritika Sharma
 
PDF
C++ Files and Streams
Ahmed Farag
 
PDF
Operator overloading
Pranali Chaudhari
 
PPT
Input and output in C++
Nilesh Dalvi
 
PPTX
Friend function
zindadili
 
PPTX
Constructors in C++
RubaNagarajan
 
PPTX
Templates in c++
ThamizhselviKrishnam
 
PPTX
[OOP - Lec 19] Static Member Functions
Muhammad Hammad Waseem
 
PDF
Constructor and Destructor
Kamal Acharya
 
PPTX
Static Data Members and Member Functions
MOHIT AGARWAL
 
PPTX
Constructor and destructor
Shubham Vishwambhar
 
PPS
Wrapper class
kamal kotecha
 
Friend function & friend class
Abhishek Wadhwa
 
class and objects
Payel Guria
 
Class and Objects in Java
Spotle.ai
 
Inner classes in java
PhD Research Scholar
 
Friend function in c++
University of Madras
 
Array of objects.pptx
RAGAVIC2
 
Oop c++class(final).ppt
Alok Kumar
 
Inner class
Guna Sekaran
 
friend function(c++)
Ritika Sharma
 
C++ Files and Streams
Ahmed Farag
 
Operator overloading
Pranali Chaudhari
 
Input and output in C++
Nilesh Dalvi
 
Friend function
zindadili
 
Constructors in C++
RubaNagarajan
 
Templates in c++
ThamizhselviKrishnam
 
[OOP - Lec 19] Static Member Functions
Muhammad Hammad Waseem
 
Constructor and Destructor
Kamal Acharya
 
Static Data Members and Member Functions
MOHIT AGARWAL
 
Constructor and destructor
Shubham Vishwambhar
 
Wrapper class
kamal kotecha
 

Similar to Class and object in c++ (20)

PPT
classandobjectunit2-150824133722-lva1-app6891.ppt
manomkpsg
 
PPTX
Object Oriented Programming Using C++
Muhammad Waqas
 
PPTX
Class and object
prabhat kumar
 
PPTX
Oops
Jaya Kumari
 
PDF
Class and object
Prof. Dr. K. Adisesha
 
PPT
Classes in C++ computer language presentation.ppt
AjayLobo1
 
PPTX
Lecture 4. mte 407
rumanatasnim415
 
PDF
oops-123991513147-phpapp02.pdf
ArpitaJana28
 
PPTX
Class-١.pptx vbdbbdndgngngndngnnfndfnngn
YoussefSameh20
 
PPT
cpp class unitdfdsfasadfsdASsASass 4.ppt
nandemprasanna
 
PPT
4 Classes & Objects
Praveen M Jigajinni
 
PPTX
week 2 - classes and objects of object ori9ented programming .pptx
farooqabubakar4000
 
PPT
Classes, objects and methods
farhan amjad
 
DOC
My c++
snathick
 
PDF
Learn C# Programming - Classes & Inheritance
Eng Teong Cheah
 
PPTX
classes-objects in oops java-201023154255.pptx
janetvidyaanancys
 
PPTX
Classes
Sheheryar Gull
 
PPT
Classes & objects new
lykado0dles
 
PPTX
Object Oriented Programming Class and Objects
rubini8582
 
classandobjectunit2-150824133722-lva1-app6891.ppt
manomkpsg
 
Object Oriented Programming Using C++
Muhammad Waqas
 
Class and object
prabhat kumar
 
Class and object
Prof. Dr. K. Adisesha
 
Classes in C++ computer language presentation.ppt
AjayLobo1
 
Lecture 4. mte 407
rumanatasnim415
 
oops-123991513147-phpapp02.pdf
ArpitaJana28
 
Class-١.pptx vbdbbdndgngngndngnnfndfnngn
YoussefSameh20
 
cpp class unitdfdsfasadfsdASsASass 4.ppt
nandemprasanna
 
4 Classes & Objects
Praveen M Jigajinni
 
week 2 - classes and objects of object ori9ented programming .pptx
farooqabubakar4000
 
Classes, objects and methods
farhan amjad
 
My c++
snathick
 
Learn C# Programming - Classes & Inheritance
Eng Teong Cheah
 
classes-objects in oops java-201023154255.pptx
janetvidyaanancys
 
Classes & objects new
lykado0dles
 
Object Oriented Programming Class and Objects
rubini8582
 
Ad

More from NainaKhan28 (7)

PPT
C++ constructors
NainaKhan28
 
PPT
creating objects and Class methods
NainaKhan28
 
PPT
Function in C++
NainaKhan28
 
PPT
Computer network
NainaKhan28
 
PPTX
Computational technique
NainaKhan28
 
PPT
Software Development Life Cycle Model
NainaKhan28
 
PPTX
Data Communication
NainaKhan28
 
C++ constructors
NainaKhan28
 
creating objects and Class methods
NainaKhan28
 
Function in C++
NainaKhan28
 
Computer network
NainaKhan28
 
Computational technique
NainaKhan28
 
Software Development Life Cycle Model
NainaKhan28
 
Data Communication
NainaKhan28
 
Ad

Recently uploaded (20)

PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PDF
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
PDF
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PDF
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 

Class and object in c++

  • 2. Introduction to C++ Classes and Objects The classes are the most important feature of C++ that leads to Object Oriented programming. Class is a user defined data type, which holds its own data members and member functions, which can be accessed and used by creating instance of that class.
  • 3. The variables inside class definition are called as data members and the functions are called member functions.
  • 4. example: Class of birds, all birds can fly and they all have wings and beaks. So here flying is a behavior and wings and beaks are part of their characteristics. And there are many different birds in this class with different names but they all posses this behavior and characteristics.
  • 5. Similarly, class is just a blue print, which declares and defines characteristics and behavior, namely data members and member functions respectively. And all objects of this class will share these characteristics and behavior.
  • 6. Objects of Classes Objects are instances of class, which holds the data variables declared in class and the member functions work on these class objects. Each object has different data variables.
  • 7. Objects are initialized using special class functions called Constructors. And whenever the object is out of its scope, another special class member function called Destructor is called, to release the memory reserved by the object.
  • 8. Example class Abc { int x; void display() { // some statement } }; int main() { Abc obj; // Object of class Abc created }