ݺߣ

ݺߣShare a Scribd company logo
structs that only contain variables represent the traditional non-object-oriented
programming world, as they can only hold data.
In the world of object-oriented programming, we often want our types to not
only hold data, but provide functions that work with the data as well.
In C++, this is typically done via the .
keyword defines a new user-defined type.
struct
class
the only significant difference is the public keyword in the class.
declaration does not declare any memory. It only defines what the
class looks like
DateClass today { 2020, 10, 14 }; // declare a variable of class DateClass
Defining a variable of a class we call it instantiating the class.
The variable is called an instance, of the class
A variable of a class type is also called an object.
Instantiating an object (e.g. DateClass today) allocates memory for that object.
Classes can also contain functions.
Functions defined inside of a class are
called member functions ( methods).
Member functions can be defined inside or
outside of the class definition.
Function member
When we call “today.print()”, we’re telling the
compiler to call the print() member function,
associated with the today object.
Using the “m_” prefix for member
variables helps distinguish member
variables from function parameters or
local variables inside member functions.
when we see an assignment to a
variable with the “m_” prefix  we are
changing the state of the class.
Unlike function parameters or local
variables, which are declared within the
function, member variables are declared
in the class definition.
Rule!!!! Name your classes starting with
a capital letter.
A class that allocates memory will deallocate it before
being destroyed), but it’s not safe to assume a struct will.
we recommend using the struct keyword for data-only
structures, and the class keyword for defining objects that
require both data and functions to be bundled together.
Classes form the basis for Object-oriented programming
Access specifiers determine who has
access to the members that follow the
specifier.
1
public
2
private
3
protected
Public members are members of a struct or class that can be accessed from outside of
the struct or class.
Private members are members of a class that can only be accessed by other
members of the class.
All members of a struct are public members by default.
All members of a class are private members by default.
error!!!
In general, member variables are usually made private, and member functions are usually
made public.
base and height

More Related Content

Similar to Class-١.pptx vbdbbdndgngngndngnnfndfnngn (20)

Class and object
Class and objectClass and object
Class and object
prabhat kumar
oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdf
ArpitaJana28
Classes, objects and methods
Classes, objects and methodsClasses, objects and methods
Classes, objects and methods
farhan amjad
My c++
My c++My c++
My c++
snathick
Oops
OopsOops
Oops
Jaya Kumari
Classes & objects new
Classes & objects newClasses & objects new
Classes & objects new
lykado0dles
OOPS IN PHP.pptx
OOPS IN PHP.pptxOOPS IN PHP.pptx
OOPS IN PHP.pptx
rani marri
struct and class deferences
 struct and class deferences struct and class deferences
struct and class deferences
Naseer Khan Noor
cpp class unitdfdsfasadfsdASsASass 4.ppt
cpp class unitdfdsfasadfsdASsASass 4.pptcpp class unitdfdsfasadfsdASsASass 4.ppt
cpp class unitdfdsfasadfsdASsASass 4.ppt
nandemprasanna
Jedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented conceptsJedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented concepts
Maryo Manjaruni
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
Muhammad Waqas
class and object in c++.pptx
class and object in c++.pptxclass and object in c++.pptx
class and object in c++.pptx
Adarsh College, Hingoli
Class objects oopm
Class objects oopmClass objects oopm
Class objects oopm
Shweta Shah
static member and static member fumctions.ppt
static member and static member fumctions.pptstatic member and static member fumctions.ppt
static member and static member fumctions.ppt
poojitsaid2021
Classes and objects
Classes and objectsClasses and objects
Classes and objects
Lovely Professional University
Member Function in C++
Member Function in C++Member Function in C++
Member Function in C++
AbhishekSaini132328
Member Function in C++
Member Function in C++ Member Function in C++
Member Function in C++
NikitaKaur10
Classes-and-Objects-in-C++.pdf
Classes-and-Objects-in-C++.pdfClasses-and-Objects-in-C++.pdf
Classes-and-Objects-in-C++.pdf
ismartshanker1
Class and object
Class and objectClass and object
Class and object
Prof. Dr. K. Adisesha
Interview preparation for programming.pptx
Interview preparation for programming.pptxInterview preparation for programming.pptx
Interview preparation for programming.pptx
BilalHussainShah5

More from YoussefSameh20 (6)

Geneva Mechanism (1 hbhbkjbjbkj'ok).pptx
Geneva Mechanism (1 hbhbkjbjbkj'ok).pptxGeneva Mechanism (1 hbhbkjbjbkj'ok).pptx
Geneva Mechanism (1 hbhbkjbjbkj'ok).pptx
YoussefSameh20
Geneva Mechanism-1ddddddddddffrrrrr.pptx
Geneva Mechanism-1ddddddddddffrrrrr.pptxGeneva Mechanism-1ddddddddddffrrrrr.pptx
Geneva Mechanism-1ddddddddddffrrrrr.pptx
YoussefSameh20
PROJECT REPORT ONdfervrvvrtvrvrttvr.pptx
PROJECT REPORT ONdfervrvvrtvrvrttvr.pptxPROJECT REPORT ONdfervrvvrtvrvrttvr.pptx
PROJECT REPORT ONdfervrvvrtvrvrttvr.pptx
YoussefSameh20
تنمية_الإبداع_غيثة.ppt nkh..mmvvgfjfjjhj
تنمية_الإبداع_غيثة.ppt nkh..mmvvgfjfjjhjتنمية_الإبداع_غيثة.ppt nkh..mmvvgfjfjjhj
تنمية_الإبداع_غيثة.ppt nkh..mmvvgfjfjjhj
YoussefSameh20
تيننثثمظثظثظظثظززقوقوقنقتستطيع مدني.pptx
تيننثثمظثظثظظثظززقوقوقنقتستطيع مدني.pptxتيننثثمظثظثظظثظززقوقوقنقتستطيع مدني.pptx
تيننثثمظثظثظظثظززقوقوقنقتستطيع مدني.pptx
YoussefSameh20
Casting-Defects-ppt.pptx Casting-Defects _Casting-Defects _Casting-Defects _...
Casting-Defects-ppt.pptx  Casting-Defects _Casting-Defects _Casting-Defects _...Casting-Defects-ppt.pptx  Casting-Defects _Casting-Defects _Casting-Defects _...
Casting-Defects-ppt.pptx Casting-Defects _Casting-Defects _Casting-Defects _...
YoussefSameh20
Geneva Mechanism (1 hbhbkjbjbkj'ok).pptx
Geneva Mechanism (1 hbhbkjbjbkj'ok).pptxGeneva Mechanism (1 hbhbkjbjbkj'ok).pptx
Geneva Mechanism (1 hbhbkjbjbkj'ok).pptx
YoussefSameh20
Geneva Mechanism-1ddddddddddffrrrrr.pptx
Geneva Mechanism-1ddddddddddffrrrrr.pptxGeneva Mechanism-1ddddddddddffrrrrr.pptx
Geneva Mechanism-1ddddddddddffrrrrr.pptx
YoussefSameh20
PROJECT REPORT ONdfervrvvrtvrvrttvr.pptx
PROJECT REPORT ONdfervrvvrtvrvrttvr.pptxPROJECT REPORT ONdfervrvvrtvrvrttvr.pptx
PROJECT REPORT ONdfervrvvrtvrvrttvr.pptx
YoussefSameh20
تنمية_الإبداع_غيثة.ppt nkh..mmvvgfjfjjhj
تنمية_الإبداع_غيثة.ppt nkh..mmvvgfjfjjhjتنمية_الإبداع_غيثة.ppt nkh..mmvvgfjfjjhj
تنمية_الإبداع_غيثة.ppt nkh..mmvvgfjfjjhj
YoussefSameh20
تيننثثمظثظثظظثظززقوقوقنقتستطيع مدني.pptx
تيننثثمظثظثظظثظززقوقوقنقتستطيع مدني.pptxتيننثثمظثظثظظثظززقوقوقنقتستطيع مدني.pptx
تيننثثمظثظثظظثظززقوقوقنقتستطيع مدني.pptx
YoussefSameh20
Casting-Defects-ppt.pptx Casting-Defects _Casting-Defects _Casting-Defects _...
Casting-Defects-ppt.pptx  Casting-Defects _Casting-Defects _Casting-Defects _...Casting-Defects-ppt.pptx  Casting-Defects _Casting-Defects _Casting-Defects _...
Casting-Defects-ppt.pptx Casting-Defects _Casting-Defects _Casting-Defects _...
YoussefSameh20

Recently uploaded (20)

Gauges are a Pump's Best Friend - Troubleshooting and Operations - v.07
Gauges are a Pump's Best Friend - Troubleshooting and Operations - v.07Gauges are a Pump's Best Friend - Troubleshooting and Operations - v.07
Gauges are a Pump's Best Friend - Troubleshooting and Operations - v.07
Brian Gongol
Lessons learned when managing MySQL in the Cloud
Lessons learned when managing MySQL in the CloudLessons learned when managing MySQL in the Cloud
Lessons learned when managing MySQL in the Cloud
Igor Donchovski
How Engineering Model Making Brings Designs to Life.pdf
How Engineering Model Making Brings Designs to Life.pdfHow Engineering Model Making Brings Designs to Life.pdf
How Engineering Model Making Brings Designs to Life.pdf
Maadhu Creatives-Model Making Company
Cloud Computing concepts and technologies
Cloud Computing concepts and technologiesCloud Computing concepts and technologies
Cloud Computing concepts and technologies
ssuser4c9444
Cyber Security_ Protecting the Digital World.pptx
Cyber Security_ Protecting the Digital World.pptxCyber Security_ Protecting the Digital World.pptx
Cyber Security_ Protecting the Digital World.pptx
Harshith A S
Industrial Valves, Instruments Products Profile
Industrial Valves, Instruments Products ProfileIndustrial Valves, Instruments Products Profile
Industrial Valves, Instruments Products Profile
zebcoeng
Syntax Directed Definitions Synthesized Attributes and Inherited Attributes
Syntax Directed Definitions  Synthesized Attributes  and  Inherited AttributesSyntax Directed Definitions  Synthesized Attributes  and  Inherited Attributes
Syntax Directed Definitions Synthesized Attributes and Inherited Attributes
GunjalSanjay
google_developer_group_ramdeobaba_university_EXPLORE_PPT
google_developer_group_ramdeobaba_university_EXPLORE_PPTgoogle_developer_group_ramdeobaba_university_EXPLORE_PPT
google_developer_group_ramdeobaba_university_EXPLORE_PPT
JayeshShete1
RAMSES- EDITORIAL SAMPLE FOR DSSPC C.pptx
RAMSES- EDITORIAL SAMPLE FOR DSSPC C.pptxRAMSES- EDITORIAL SAMPLE FOR DSSPC C.pptx
RAMSES- EDITORIAL SAMPLE FOR DSSPC C.pptx
JenTeruel1
Frankfurt University of Applied Science urkunde
Frankfurt University of Applied Science urkundeFrankfurt University of Applied Science urkunde
Frankfurt University of Applied Science urkunde
Lisa Emerson
15. Smart Cities Big Data, Civic Hackers, and the Quest for a New Utopia.pdf
15. Smart Cities Big Data, Civic Hackers, and the Quest for a New Utopia.pdf15. Smart Cities Big Data, Civic Hackers, and the Quest for a New Utopia.pdf
15. Smart Cities Big Data, Civic Hackers, and the Quest for a New Utopia.pdf
NgocThang9
Taykon-Kalite belgeleri
Taykon-Kalite belgeleriTaykon-Kalite belgeleri
Taykon-Kalite belgeleri
TAYKON
Piping-and-pipeline-calculations-manual.pdf
Piping-and-pipeline-calculations-manual.pdfPiping-and-pipeline-calculations-manual.pdf
Piping-and-pipeline-calculations-manual.pdf
OMI0721
How to Make an RFID Door Lock System using Arduino
How to Make an RFID Door Lock System using ArduinoHow to Make an RFID Door Lock System using Arduino
How to Make an RFID Door Lock System using Arduino
CircuitDigest
Unit II: Design of Static Equipment Foundations
Unit II: Design of Static Equipment FoundationsUnit II: Design of Static Equipment Foundations
Unit II: Design of Static Equipment Foundations
Sanjivani College of Engineering, Kopargaon
BS_EN_ISO_19650_Detailed_Presentation.pptx
BS_EN_ISO_19650_Detailed_Presentation.pptxBS_EN_ISO_19650_Detailed_Presentation.pptx
BS_EN_ISO_19650_Detailed_Presentation.pptx
VinkuMeena
Lectureof nano 1588236675-biosensors (1).ppt
Lectureof nano 1588236675-biosensors (1).pptLectureof nano 1588236675-biosensors (1).ppt
Lectureof nano 1588236675-biosensors (1).ppt
SherifElGohary7
US Patented ReGenX Generator, ReGen-X Quatum Motor EV Regenerative Accelerati...
US Patented ReGenX Generator, ReGen-X Quatum Motor EV Regenerative Accelerati...US Patented ReGenX Generator, ReGen-X Quatum Motor EV Regenerative Accelerati...
US Patented ReGenX Generator, ReGen-X Quatum Motor EV Regenerative Accelerati...
Thane Heins NOBEL PRIZE WINNING ENERGY RESEARCHER
Wireless-Charger presentation for seminar .pdf
Wireless-Charger presentation for seminar .pdfWireless-Charger presentation for seminar .pdf
Wireless-Charger presentation for seminar .pdf
AbhinandanMishra30
Integration of Additive Manufacturing (AM) with IoT : A Smart Manufacturing A...
Integration of Additive Manufacturing (AM) with IoT : A Smart Manufacturing A...Integration of Additive Manufacturing (AM) with IoT : A Smart Manufacturing A...
Integration of Additive Manufacturing (AM) with IoT : A Smart Manufacturing A...
ASHISHDESAI85
Gauges are a Pump's Best Friend - Troubleshooting and Operations - v.07
Gauges are a Pump's Best Friend - Troubleshooting and Operations - v.07Gauges are a Pump's Best Friend - Troubleshooting and Operations - v.07
Gauges are a Pump's Best Friend - Troubleshooting and Operations - v.07
Brian Gongol
Lessons learned when managing MySQL in the Cloud
Lessons learned when managing MySQL in the CloudLessons learned when managing MySQL in the Cloud
Lessons learned when managing MySQL in the Cloud
Igor Donchovski
Cloud Computing concepts and technologies
Cloud Computing concepts and technologiesCloud Computing concepts and technologies
Cloud Computing concepts and technologies
ssuser4c9444
Cyber Security_ Protecting the Digital World.pptx
Cyber Security_ Protecting the Digital World.pptxCyber Security_ Protecting the Digital World.pptx
Cyber Security_ Protecting the Digital World.pptx
Harshith A S
Industrial Valves, Instruments Products Profile
Industrial Valves, Instruments Products ProfileIndustrial Valves, Instruments Products Profile
Industrial Valves, Instruments Products Profile
zebcoeng
Syntax Directed Definitions Synthesized Attributes and Inherited Attributes
Syntax Directed Definitions  Synthesized Attributes  and  Inherited AttributesSyntax Directed Definitions  Synthesized Attributes  and  Inherited Attributes
Syntax Directed Definitions Synthesized Attributes and Inherited Attributes
GunjalSanjay
google_developer_group_ramdeobaba_university_EXPLORE_PPT
google_developer_group_ramdeobaba_university_EXPLORE_PPTgoogle_developer_group_ramdeobaba_university_EXPLORE_PPT
google_developer_group_ramdeobaba_university_EXPLORE_PPT
JayeshShete1
RAMSES- EDITORIAL SAMPLE FOR DSSPC C.pptx
RAMSES- EDITORIAL SAMPLE FOR DSSPC C.pptxRAMSES- EDITORIAL SAMPLE FOR DSSPC C.pptx
RAMSES- EDITORIAL SAMPLE FOR DSSPC C.pptx
JenTeruel1
Frankfurt University of Applied Science urkunde
Frankfurt University of Applied Science urkundeFrankfurt University of Applied Science urkunde
Frankfurt University of Applied Science urkunde
Lisa Emerson
15. Smart Cities Big Data, Civic Hackers, and the Quest for a New Utopia.pdf
15. Smart Cities Big Data, Civic Hackers, and the Quest for a New Utopia.pdf15. Smart Cities Big Data, Civic Hackers, and the Quest for a New Utopia.pdf
15. Smart Cities Big Data, Civic Hackers, and the Quest for a New Utopia.pdf
NgocThang9
Taykon-Kalite belgeleri
Taykon-Kalite belgeleriTaykon-Kalite belgeleri
Taykon-Kalite belgeleri
TAYKON
Piping-and-pipeline-calculations-manual.pdf
Piping-and-pipeline-calculations-manual.pdfPiping-and-pipeline-calculations-manual.pdf
Piping-and-pipeline-calculations-manual.pdf
OMI0721
How to Make an RFID Door Lock System using Arduino
How to Make an RFID Door Lock System using ArduinoHow to Make an RFID Door Lock System using Arduino
How to Make an RFID Door Lock System using Arduino
CircuitDigest
BS_EN_ISO_19650_Detailed_Presentation.pptx
BS_EN_ISO_19650_Detailed_Presentation.pptxBS_EN_ISO_19650_Detailed_Presentation.pptx
BS_EN_ISO_19650_Detailed_Presentation.pptx
VinkuMeena
Lectureof nano 1588236675-biosensors (1).ppt
Lectureof nano 1588236675-biosensors (1).pptLectureof nano 1588236675-biosensors (1).ppt
Lectureof nano 1588236675-biosensors (1).ppt
SherifElGohary7
Wireless-Charger presentation for seminar .pdf
Wireless-Charger presentation for seminar .pdfWireless-Charger presentation for seminar .pdf
Wireless-Charger presentation for seminar .pdf
AbhinandanMishra30
Integration of Additive Manufacturing (AM) with IoT : A Smart Manufacturing A...
Integration of Additive Manufacturing (AM) with IoT : A Smart Manufacturing A...Integration of Additive Manufacturing (AM) with IoT : A Smart Manufacturing A...
Integration of Additive Manufacturing (AM) with IoT : A Smart Manufacturing A...
ASHISHDESAI85

Class-١.pptx vbdbbdndgngngndngnnfndfnngn

  • 1. structs that only contain variables represent the traditional non-object-oriented programming world, as they can only hold data.
  • 2. In the world of object-oriented programming, we often want our types to not only hold data, but provide functions that work with the data as well. In C++, this is typically done via the . keyword defines a new user-defined type. struct class
  • 3. the only significant difference is the public keyword in the class. declaration does not declare any memory. It only defines what the class looks like DateClass today { 2020, 10, 14 }; // declare a variable of class DateClass Defining a variable of a class we call it instantiating the class. The variable is called an instance, of the class A variable of a class type is also called an object. Instantiating an object (e.g. DateClass today) allocates memory for that object. Classes can also contain functions. Functions defined inside of a class are called member functions ( methods). Member functions can be defined inside or outside of the class definition.
  • 4. Function member When we call “today.print()”, we’re telling the compiler to call the print() member function, associated with the today object.
  • 5. Using the “m_” prefix for member variables helps distinguish member variables from function parameters or local variables inside member functions. when we see an assignment to a variable with the “m_” prefix  we are changing the state of the class. Unlike function parameters or local variables, which are declared within the function, member variables are declared in the class definition. Rule!!!! Name your classes starting with a capital letter.
  • 6. A class that allocates memory will deallocate it before being destroyed), but it’s not safe to assume a struct will. we recommend using the struct keyword for data-only structures, and the class keyword for defining objects that require both data and functions to be bundled together. Classes form the basis for Object-oriented programming
  • 7. Access specifiers determine who has access to the members that follow the specifier. 1 public 2 private 3 protected
  • 8. Public members are members of a struct or class that can be accessed from outside of the struct or class. Private members are members of a class that can only be accessed by other members of the class. All members of a struct are public members by default. All members of a class are private members by default. error!!!
  • 9. In general, member variables are usually made private, and member functions are usually made public.