SlideShare a Scribd company logo
Material 14
Structures and Classes in C++
• Structures in C++ differ from those in C in that
members can be functions.
• A special member function is the “constructor”,
whose name is the same as the structure. It is
used to initialize the object:
struct buffer {
buffer()
{size=MAXBUF+1; front=rear=0;}
char buf[MAXBUF+1];
int size, front, rear;
}
Structures and Classes in C++
The idea is to add some operations on objects
of type buffer:
struct buffer {
buffer() {size=MAXBUF+1;front=rear=0;}
char buf[MAXBUF+1];
int size, front, rear;
int succ(int i) {return (i+1)%size;}
int enter(char);
char leave();
}
Structures and Classes in C++
The definition (body) of a member function can be
included in the structure's declaration, or may
appear later. If so, use the name resolution
operator (::)
int buffer::enter(char x) {
// body of enter }
char buffer::leave() {
// body of leave }

More Related Content

What's hot

Devry gsp 215 week 3 homework representing and manipulating information new
Devry gsp 215 week 3 homework representing and manipulating information newDevry gsp 215 week 3 homework representing and manipulating information new
Devry gsp 215 week 3 homework representing and manipulating information new
williamethan912
 
Apriori algorithm
Apriori algorithmApriori algorithm
Apriori algorithm
Junghoon Kim
 
GC3 Beamer
GC3 BeamerGC3 Beamer
GC3 Beamer
Hirwanto Iwan
 
Byte arrayoutputstream
Byte arrayoutputstreamByte arrayoutputstream
Byte arrayoutputstreammyrajendra
 
Map filter reduce in Python
Map filter reduce in PythonMap filter reduce in Python
Map filter reduce in Python
Adnan Siddiqi
 
An adaptive algorithm for detection of duplicate records
An adaptive algorithm for detection of duplicate recordsAn adaptive algorithm for detection of duplicate records
An adaptive algorithm for detection of duplicate recordsLikan Patra
 
How to use Map() Filter() and Reduce() functions in Python | Edureka
How to use Map() Filter() and Reduce() functions in Python | EdurekaHow to use Map() Filter() and Reduce() functions in Python | Edureka
How to use Map() Filter() and Reduce() functions in Python | Edureka
Edureka!
 
Dma
DmaDma
Dynamic Memory Allocation(DMA)
Dynamic Memory Allocation(DMA)Dynamic Memory Allocation(DMA)
Dynamic Memory Allocation(DMA)
Kamal Acharya
 
Malloc() and calloc() in c
Malloc() and calloc() in cMalloc() and calloc() in c
Malloc() and calloc() in c
Mahesh Tibrewal
 
Dynamic memory Allocation in c language
Dynamic memory Allocation in c languageDynamic memory Allocation in c language
Dynamic memory Allocation in c language
kiran Patel
 
Plotting data with python and pylab
Plotting data with python and pylabPlotting data with python and pylab
Plotting data with python and pylab
Giovanni Marco Dall'Olio
 
Dynamic memory allocation in c
Dynamic memory allocation in cDynamic memory allocation in c
Dynamic memory allocation in c
lavanya marichamy
 
Introduction to matplotlib
Introduction to matplotlibIntroduction to matplotlib
Introduction to matplotlib
Piyush rai
 
DB reading group may 16, 2018
DB reading group may 16, 2018DB reading group may 16, 2018
DB reading group may 16, 2018
Keisuke Suzuki
 
ELECTRICAL POWER SYSTEMS ECONOMICS
ELECTRICAL POWER SYSTEMS ECONOMICSELECTRICAL POWER SYSTEMS ECONOMICS
ELECTRICAL POWER SYSTEMS ECONOMICS
MohammedMedani4
 
16858 memory management2
16858 memory management216858 memory management2
16858 memory management2Aanand Singh
 
Introduction to numpy
Introduction to numpyIntroduction to numpy
Introduction to numpy
Gaurav Aggarwal
 
Dynamic memory allocation
Dynamic memory allocationDynamic memory allocation
Dynamic memory allocation
Burhanuddin Kapadia
 

What's hot (20)

Devry gsp 215 week 3 homework representing and manipulating information new
Devry gsp 215 week 3 homework representing and manipulating information newDevry gsp 215 week 3 homework representing and manipulating information new
Devry gsp 215 week 3 homework representing and manipulating information new
 
Apriori algorithm
Apriori algorithmApriori algorithm
Apriori algorithm
 
GC3 Beamer
GC3 BeamerGC3 Beamer
GC3 Beamer
 
Byte arrayoutputstream
Byte arrayoutputstreamByte arrayoutputstream
Byte arrayoutputstream
 
Map filter reduce in Python
Map filter reduce in PythonMap filter reduce in Python
Map filter reduce in Python
 
An adaptive algorithm for detection of duplicate records
An adaptive algorithm for detection of duplicate recordsAn adaptive algorithm for detection of duplicate records
An adaptive algorithm for detection of duplicate records
 
How to use Map() Filter() and Reduce() functions in Python | Edureka
How to use Map() Filter() and Reduce() functions in Python | EdurekaHow to use Map() Filter() and Reduce() functions in Python | Edureka
How to use Map() Filter() and Reduce() functions in Python | Edureka
 
Functions with heap and stack
Functions with heap and stackFunctions with heap and stack
Functions with heap and stack
 
Dma
DmaDma
Dma
 
Dynamic Memory Allocation(DMA)
Dynamic Memory Allocation(DMA)Dynamic Memory Allocation(DMA)
Dynamic Memory Allocation(DMA)
 
Malloc() and calloc() in c
Malloc() and calloc() in cMalloc() and calloc() in c
Malloc() and calloc() in c
 
Dynamic memory Allocation in c language
Dynamic memory Allocation in c languageDynamic memory Allocation in c language
Dynamic memory Allocation in c language
 
Plotting data with python and pylab
Plotting data with python and pylabPlotting data with python and pylab
Plotting data with python and pylab
 
Dynamic memory allocation in c
Dynamic memory allocation in cDynamic memory allocation in c
Dynamic memory allocation in c
 
Introduction to matplotlib
Introduction to matplotlibIntroduction to matplotlib
Introduction to matplotlib
 
DB reading group may 16, 2018
DB reading group may 16, 2018DB reading group may 16, 2018
DB reading group may 16, 2018
 
ELECTRICAL POWER SYSTEMS ECONOMICS
ELECTRICAL POWER SYSTEMS ECONOMICSELECTRICAL POWER SYSTEMS ECONOMICS
ELECTRICAL POWER SYSTEMS ECONOMICS
 
16858 memory management2
16858 memory management216858 memory management2
16858 memory management2
 
Introduction to numpy
Introduction to numpyIntroduction to numpy
Introduction to numpy
 
Dynamic memory allocation
Dynamic memory allocationDynamic memory allocation
Dynamic memory allocation
 

Viewers also liked

Lo18
Lo18Lo18
Lo18
liankei
 
08
0808
Lo12
Lo12Lo12
Lo12
liankei
 
Lo9
Lo9Lo9
Lo9
liankei
 
Lo17
Lo17Lo17
Lo17
liankei
 
Lo7
Lo7Lo7
Lo7
liankei
 
Lo15
Lo15Lo15
Lo15
liankei
 
Lo4
Lo4Lo4
Lo4
liankei
 
Lo19
Lo19Lo19
Lo19
liankei
 
Lo5
Lo5Lo5
Lo5
liankei
 
Lo13
Lo13Lo13
Lo13
liankei
 
Lo8
Lo8Lo8
Lo8
liankei
 
Lo2
Lo2Lo2
Lo2
liankei
 
Lo16
Lo16Lo16
Lo16
liankei
 
Lo11
Lo11Lo11
Lo11
liankei
 
Lo20
Lo20Lo20
Lo20
liankei
 
Lo10
Lo10Lo10
Lo10
liankei
 
01
0101
02
0202

Viewers also liked (19)

Lo18
Lo18Lo18
Lo18
 
08
0808
08
 
Lo12
Lo12Lo12
Lo12
 
Lo9
Lo9Lo9
Lo9
 
Lo17
Lo17Lo17
Lo17
 
Lo7
Lo7Lo7
Lo7
 
Lo15
Lo15Lo15
Lo15
 
Lo4
Lo4Lo4
Lo4
 
Lo19
Lo19Lo19
Lo19
 
Lo5
Lo5Lo5
Lo5
 
Lo13
Lo13Lo13
Lo13
 
Lo8
Lo8Lo8
Lo8
 
Lo2
Lo2Lo2
Lo2
 
Lo16
Lo16Lo16
Lo16
 
Lo11
Lo11Lo11
Lo11
 
Lo20
Lo20Lo20
Lo20
 
Lo10
Lo10Lo10
Lo10
 
01
0101
01
 
02
0202
02
 

Similar to Lo14

L6
L6L6
L6
lksoo
 
Review constdestr
Review constdestrReview constdestr
Review constdestrrajudasraju
 
Constructor and Destructor PPT
Constructor and Destructor PPTConstructor and Destructor PPT
Constructor and Destructor PPT
Shubham Mondal
 
ReviewConstructorDestructorof cplusplus.ppt
ReviewConstructorDestructorof cplusplus.pptReviewConstructorDestructorof cplusplus.ppt
ReviewConstructorDestructorof cplusplus.ppt
aavvv
 
C++ language
C++ languageC++ language
C++ language
Hamza Asif
 
concepts of object and classes in OOPS.pptx
concepts of object and classes in OOPS.pptxconcepts of object and classes in OOPS.pptx
concepts of object and classes in OOPS.pptx
urvashipundir04
 
OO-like C Programming: Struct Inheritance and Virtual Function
OO-like C Programming: Struct Inheritance and Virtual FunctionOO-like C Programming: Struct Inheritance and Virtual Function
OO-like C Programming: Struct Inheritance and Virtual Function
Yu-Sheng (Yosen) Chen
 
Functions.pptx
Functions.pptxFunctions.pptx
Functions.pptx
AhmedHashim242567
 
C++ tutorial boost – 2013
C++ tutorial   boost – 2013C++ tutorial   boost – 2013
C++ tutorial boost – 2013
Ratsietsi Mokete
 
UNIT3 on object oriented programming.pptx
UNIT3 on object oriented programming.pptxUNIT3 on object oriented programming.pptx
UNIT3 on object oriented programming.pptx
urvashipundir04
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
Srikanth Mylapalli
 
Presentation on C++ Programming Language
Presentation on C++ Programming LanguagePresentation on C++ Programming Language
Presentation on C++ Programming Language
satvirsandhu9
 
Memory Management In C++
Memory Management In C++Memory Management In C++
Memory Management In C++
ShriKant Vashishtha
 
Tutconstructordes
TutconstructordesTutconstructordes
TutconstructordesNiti Arora
 
OOP
OOPOOP
Learning C++ - Functions in C++ 3
Learning C++ - Functions  in C++ 3Learning C++ - Functions  in C++ 3
Learning C++ - Functions in C++ 3
Ali Aminian
 
C++.pptx
C++.pptxC++.pptx
C questions
C questionsC questions
C questions
parm112
 

Similar to Lo14 (20)

L6
L6L6
L6
 
Review constdestr
Review constdestrReview constdestr
Review constdestr
 
Constructor and Destructor PPT
Constructor and Destructor PPTConstructor and Destructor PPT
Constructor and Destructor PPT
 
ReviewConstructorDestructorof cplusplus.ppt
ReviewConstructorDestructorof cplusplus.pptReviewConstructorDestructorof cplusplus.ppt
ReviewConstructorDestructorof cplusplus.ppt
 
C++ language
C++ languageC++ language
C++ language
 
Lecture5
Lecture5Lecture5
Lecture5
 
concepts of object and classes in OOPS.pptx
concepts of object and classes in OOPS.pptxconcepts of object and classes in OOPS.pptx
concepts of object and classes in OOPS.pptx
 
OO-like C Programming: Struct Inheritance and Virtual Function
OO-like C Programming: Struct Inheritance and Virtual FunctionOO-like C Programming: Struct Inheritance and Virtual Function
OO-like C Programming: Struct Inheritance and Virtual Function
 
Functions.pptx
Functions.pptxFunctions.pptx
Functions.pptx
 
C++ tutorial boost – 2013
C++ tutorial   boost – 2013C++ tutorial   boost – 2013
C++ tutorial boost – 2013
 
UNIT3 on object oriented programming.pptx
UNIT3 on object oriented programming.pptxUNIT3 on object oriented programming.pptx
UNIT3 on object oriented programming.pptx
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
Presentation on C++ Programming Language
Presentation on C++ Programming LanguagePresentation on C++ Programming Language
Presentation on C++ Programming Language
 
Overloading
OverloadingOverloading
Overloading
 
Memory Management In C++
Memory Management In C++Memory Management In C++
Memory Management In C++
 
Tutconstructordes
TutconstructordesTutconstructordes
Tutconstructordes
 
OOP
OOPOOP
OOP
 
Learning C++ - Functions in C++ 3
Learning C++ - Functions  in C++ 3Learning C++ - Functions  in C++ 3
Learning C++ - Functions in C++ 3
 
C++.pptx
C++.pptxC++.pptx
C++.pptx
 
C questions
C questionsC questions
C questions
 

More from liankei

Lo 19
Lo 19Lo 19
Lo 19
liankei
 
Lo 18
Lo 18Lo 18
Lo 18
liankei
 
Lo 13
Lo 13Lo 13
Lo 13
liankei
 
Lo 12
Lo 12Lo 12
Lo 12
liankei
 
Lo 11
Lo 11Lo 11
Lo 11
liankei
 
Lo 06
Lo 06Lo 06
Lo 06
liankei
 
Lo 05
Lo 05Lo 05
Lo 05
liankei
 
Lo 04
Lo 04Lo 04
Lo 04
liankei
 
Lo 01
Lo 01Lo 01
Lo 01
liankei
 
Lo 16
Lo 16Lo 16
Lo 16
liankei
 
Lo 15
Lo 15Lo 15
Lo 15
liankei
 
Lo 09
Lo 09Lo 09
Lo 09
liankei
 
Lo 08
Lo 08Lo 08
Lo 08
liankei
 
Lo 03
Lo 03Lo 03
Lo 03
liankei
 
Lo 20
Lo 20Lo 20
Lo 20
liankei
 
Lo6
Lo6Lo6
Lo6
liankei
 

More from liankei (16)

Lo 19
Lo 19Lo 19
Lo 19
 
Lo 18
Lo 18Lo 18
Lo 18
 
Lo 13
Lo 13Lo 13
Lo 13
 
Lo 12
Lo 12Lo 12
Lo 12
 
Lo 11
Lo 11Lo 11
Lo 11
 
Lo 06
Lo 06Lo 06
Lo 06
 
Lo 05
Lo 05Lo 05
Lo 05
 
Lo 04
Lo 04Lo 04
Lo 04
 
Lo 01
Lo 01Lo 01
Lo 01
 
Lo 16
Lo 16Lo 16
Lo 16
 
Lo 15
Lo 15Lo 15
Lo 15
 
Lo 09
Lo 09Lo 09
Lo 09
 
Lo 08
Lo 08Lo 08
Lo 08
 
Lo 03
Lo 03Lo 03
Lo 03
 
Lo 20
Lo 20Lo 20
Lo 20
 
Lo6
Lo6Lo6
Lo6
 

Recently uploaded

Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 

Recently uploaded (20)

Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 

Lo14

  • 2. Structures and Classes in C++ • Structures in C++ differ from those in C in that members can be functions. • A special member function is the “constructor”, whose name is the same as the structure. It is used to initialize the object: struct buffer { buffer() {size=MAXBUF+1; front=rear=0;} char buf[MAXBUF+1]; int size, front, rear; }
  • 3. Structures and Classes in C++ The idea is to add some operations on objects of type buffer: struct buffer { buffer() {size=MAXBUF+1;front=rear=0;} char buf[MAXBUF+1]; int size, front, rear; int succ(int i) {return (i+1)%size;} int enter(char); char leave(); }
  • 4. Structures and Classes in C++ The definition (body) of a member function can be included in the structure's declaration, or may appear later. If so, use the name resolution operator (::) int buffer::enter(char x) { // body of enter } char buffer::leave() { // body of leave }