SlideShare a Scribd company logo
1 of 10
Download to read offline
Universidade Federal de Alagoas :: Campus A. C. Simões Geometric Modeling and Computer Vision Laboratory
Minimal Introduction to C++
A Approach Directed to Resolution of Practical Problems
Michel Alves dos Santos
Universidade Federal de Alagoas, Campus A. C. Simões
Tabuleiro do Martins - Maceió - AL, CEP: 57072-970
Part III - Mechanisms of Inheritance and Polymorphism
{michel.mas}@gmail.com
February 14, 2013
Minimal Introduction to C++ Language - Michel Alves A Approach Directed to Resolution of Pratical Problems
Universidade Federal de Alagoas :: Campus A. C. Simões Geometric Modeling and Computer Vision Laboratory
Inheritance and Polymorphism
Mechanisms of Inheritance and Polymorphism
What happens in this figure?
Minimal Introduction to C++ Language - Michel Alves A Approach Directed to Resolution of Pratical Problems
Universidade Federal de Alagoas :: Campus A. C. Simões Geometric Modeling and Computer Vision Laboratory
What is Inheritance?
The Concept of Inheritance
Inheritance is a mechanism of reusing and extending
existing classes without modifying them, thus
producing hierarchical relationships between them.
§ ¤
1 c l a s s Polygon { /∗Some code . . . ∗/ };
2 c l a s s T r i a n g l e : p u b l i c Polygon { /∗Some code . . . ∗/ };
3 c l a s s Rectangle : p u b l i c Polygon { /∗Some code . . . ∗/ };
¦ ¥
Minimal Introduction to C++ Language - Michel Alves A Approach Directed to Resolution of Pratical Problems
Universidade Federal de Alagoas :: Campus A. C. Simões Geometric Modeling and Computer Vision Laboratory
What is Polymorphism?
The Concept of Polymorphism
Polymorphism is the ability of objects belonging to
different types to respond to method, field, or
property calls of the same name, each one according
to an appropriate type-specific behavior.
Entities that have more than one form.
§ ¤
1 /∗ Example : the + ( p l u s ) o p e r a t o r i n C++∗/
2
3 4 + 5 // i n t e g e r a d d i t i o n
4 3.14 + 2.0 // f l o a t i n g p o i n t a d d i t i o n
5 " foo " + " bar " // s t r i n g c o n c a t e n a t i o n !
6
7 /∗ In C++, that type of polymorphism i s c a l l e d o v e r l o a d i n g ∗/
¦ ¥
Polymorphism means that some code or operations or objects behave differently in different
contexts.
Minimal Introduction to C++ Language - Michel Alves A Approach Directed to Resolution of Pratical Problems
Universidade Federal de Alagoas :: Campus A. C. Simões Geometric Modeling and Computer Vision Laboratory
Inheritance and Polymorphism: Examples
Some Examples of Inheritance and Polymorphism
What is the importance of abstract classes?
Minimal Introduction to C++ Language - Michel Alves A Approach Directed to Resolution of Pratical Problems
Universidade Federal de Alagoas :: Campus A. C. Simões Geometric Modeling and Computer Vision Laboratory
Polymorphism in C++
Types of Polymorphism in C++
• Subtype Polymorphism (Runtime Polymorphism).
• Parametric Polymorphism (Compile-Time Polymorphism).
• Ad-hoc Polymorphism (Overloading).
• Coercion Polymorphism (Casting).
Minimal Introduction to C++ Language - Michel Alves A Approach Directed to Resolution of Pratical Problems
Universidade Federal de Alagoas :: Campus A. C. Simões Geometric Modeling and Computer Vision Laboratory
Polymorphism in C++: Code Example
Code Example
§ ¤
1 /∗ Base c l a s s ∗/
2 c l a s s F e l i d { p u b l i c : v i r t u a l v o i d meow( ) = 0 ; };
3
4 /∗ S u b c l a s s e s ∗/
5 c l a s s Cat : p u b l i c F e l i d { p u b l i c : v o i d meow( ) { cout << "meow! n" ; }};
6 c l a s s Tiger : p u b l i c F e l i d { p u b l i c : v o i d meow( ) { cout << "MREOW! n" ; }};
7 c l a s s Ocelot : p u b l i c F e l i d { p u b l i c : v o i d meow( ) { cout << "mews! n" ; }};
¦ ¥
§ ¤
1 template <c l a s s T> T max(T a , T b ) { r e t u r n a > b ? a : b ;}
2
3 i n t main ( )
4 {
5 std : : cout << max (9 , 5) << " t " << max( " foo " , " bar " ) << std : : e ndl ; // 9 foo
6 r e t u r n 0 ;
7 }
¦ ¥
§ ¤
1 3.14 + 2.0 // f l o a t i n g p o i n t a d d i t i o n
2 " foo " + " bar " // s t r i n g c o n c a t e n a t i o n !
¦ ¥
§ ¤
1 f l o a t b = 6 ; // i n t g et s promoted ( c a s t ) to f l o a t i m p l i c i t l y
2 i n t a = 9.99 // f l o a t g et s demoted to i n t i m p l i c i t l y
¦ ¥
Minimal Introduction to C++ Language - Michel Alves A Approach Directed to Resolution of Pratical Problems
Universidade Federal de Alagoas :: Campus A. C. Simões Geometric Modeling and Computer Vision Laboratory
Solved Problems
A List of Solved Problems
1 The Hierarchy of Polygon Class.
• Build a system that can represent the hierarchy of
polygons. The base action of this hierarchy must
be area.
2 The Area of Any Function or Curve j.
• Build a program that can calculate the area of any
function or curve using the methods of rectangle
and trapezium.
Minimal Introduction to C++ Language - Michel Alves A Approach Directed to Resolution of Pratical Problems
Universidade Federal de Alagoas :: Campus A. C. Simões Geometric Modeling and Computer Vision Laboratory
Exercises to Home
• Problem: The Hierarchy of Sorting Algorithms
• Build a minimal system that can represent the
hierarchy of sorting algorithms considering ours
complexity.
• Algorithms that must be implemented: bubble, insertion, quick and merge.
• Polyhedron Representation
• Build a minimal system that can represent
regular polyhedrons. The base class
Polyhedron must has the follow methods:
• is_regular, area, volume, edge_length.
Minimal Introduction to C++ Language - Michel Alves A Approach Directed to Resolution of Pratical Problems
Universidade Federal de Alagoas :: Campus A. C. Simões Geometric Modeling and Computer Vision Laboratory
Thanks
Thanks for your attention!
Michel Alves dos Santos - michel.mas@gmail.com
Minimal Introduction to C++ Language - Michel Alves A Approach Directed to Resolution of Pratical Problems

More Related Content

Viewers also liked

TMS - Schedule of Presentations and Reports
TMS - Schedule of Presentations and ReportsTMS - Schedule of Presentations and Reports
TMS - Schedule of Presentations and ReportsMichel Alves
 
FLTK Summer Course - Part II - Second Impact
FLTK Summer Course - Part II - Second ImpactFLTK Summer Course - Part II - Second Impact
FLTK Summer Course - Part II - Second ImpactMichel Alves
 
Capacity-Constrained Point Distributions :: Density Function Catalog
Capacity-Constrained Point Distributions :: Density Function CatalogCapacity-Constrained Point Distributions :: Density Function Catalog
Capacity-Constrained Point Distributions :: Density Function CatalogMichel Alves
 
Five Minute Speech - Building a Prototype for a Lightweight Image Processing ...
Five Minute Speech - Building a Prototype for a Lightweight Image Processing ...Five Minute Speech - Building a Prototype for a Lightweight Image Processing ...
Five Minute Speech - Building a Prototype for a Lightweight Image Processing ...Michel Alves
 
Introduction to Image Processing - Short Course - Part III
Introduction to Image Processing - Short Course - Part IIIIntroduction to Image Processing - Short Course - Part III
Introduction to Image Processing - Short Course - Part IIIMichel Alves
 
Documentation - Element and ElementVector
Documentation - Element and ElementVectorDocumentation - Element and ElementVector
Documentation - Element and ElementVectorMichel Alves
 
Capacity-Constrained Point Distributions :: Video Slides
Capacity-Constrained Point Distributions :: Video SlidesCapacity-Constrained Point Distributions :: Video Slides
Capacity-Constrained Point Distributions :: Video SlidesMichel Alves
 
FLTK Summer Course - Part IV - Fourth Impact
FLTK Summer Course - Part IV - Fourth ImpactFLTK Summer Course - Part IV - Fourth Impact
FLTK Summer Course - Part IV - Fourth ImpactMichel Alves
 
Documentation - Reference Manual - SysSorting
Documentation - Reference Manual - SysSortingDocumentation - Reference Manual - SysSorting
Documentation - Reference Manual - SysSortingMichel Alves
 
C++ Introduction
C++ IntroductionC++ Introduction
C++ Introductionparmsidhu
 
Introduction to C++
Introduction to C++ Introduction to C++
Introduction to C++ Bharat Kalia
 
Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1Ali Aminian
 
An Introduction to C++ A complete beginners guide - Michael Oliver
An Introduction to C++ A complete beginners guide - Michael OliverAn Introduction to C++ A complete beginners guide - Michael Oliver
An Introduction to C++ A complete beginners guide - Michael Olivercttvl
 
C++ Programming Course
C++ Programming CourseC++ Programming Course
C++ Programming CourseDennis Chang
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming ConceptsAbhigyan Singh Yadav
 
Intro to C++ Basic
Intro to C++ BasicIntro to C++ Basic
Intro to C++ BasicShih Chi Lin
 
Basic Data Types in C++
Basic Data Types in C++ Basic Data Types in C++
Basic Data Types in C++ Hridoy Bepari
 

Viewers also liked (20)

TMS - Schedule of Presentations and Reports
TMS - Schedule of Presentations and ReportsTMS - Schedule of Presentations and Reports
TMS - Schedule of Presentations and Reports
 
FLTK Summer Course - Part II - Second Impact
FLTK Summer Course - Part II - Second ImpactFLTK Summer Course - Part II - Second Impact
FLTK Summer Course - Part II - Second Impact
 
Capacity-Constrained Point Distributions :: Density Function Catalog
Capacity-Constrained Point Distributions :: Density Function CatalogCapacity-Constrained Point Distributions :: Density Function Catalog
Capacity-Constrained Point Distributions :: Density Function Catalog
 
Five Minute Speech - Building a Prototype for a Lightweight Image Processing ...
Five Minute Speech - Building a Prototype for a Lightweight Image Processing ...Five Minute Speech - Building a Prototype for a Lightweight Image Processing ...
Five Minute Speech - Building a Prototype for a Lightweight Image Processing ...
 
Introduction to Image Processing - Short Course - Part III
Introduction to Image Processing - Short Course - Part IIIIntroduction to Image Processing - Short Course - Part III
Introduction to Image Processing - Short Course - Part III
 
Documentation - Element and ElementVector
Documentation - Element and ElementVectorDocumentation - Element and ElementVector
Documentation - Element and ElementVector
 
Capacity-Constrained Point Distributions :: Video Slides
Capacity-Constrained Point Distributions :: Video SlidesCapacity-Constrained Point Distributions :: Video Slides
Capacity-Constrained Point Distributions :: Video Slides
 
FLTK Summer Course - Part IV - Fourth Impact
FLTK Summer Course - Part IV - Fourth ImpactFLTK Summer Course - Part IV - Fourth Impact
FLTK Summer Course - Part IV - Fourth Impact
 
Documentation - Reference Manual - SysSorting
Documentation - Reference Manual - SysSortingDocumentation - Reference Manual - SysSorting
Documentation - Reference Manual - SysSorting
 
C++ Introduction
C++ IntroductionC++ Introduction
C++ Introduction
 
Intro to c++
Intro to c++Intro to c++
Intro to c++
 
Introduction to C++
Introduction to C++ Introduction to C++
Introduction to C++
 
Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1
 
Getting Started with C++
Getting Started with C++Getting Started with C++
Getting Started with C++
 
An Introduction to C++ A complete beginners guide - Michael Oliver
An Introduction to C++ A complete beginners guide - Michael OliverAn Introduction to C++ A complete beginners guide - Michael Oliver
An Introduction to C++ A complete beginners guide - Michael Oliver
 
C++ Presentation
C++ PresentationC++ Presentation
C++ Presentation
 
C++ Programming Course
C++ Programming CourseC++ Programming Course
C++ Programming Course
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
Intro to C++ Basic
Intro to C++ BasicIntro to C++ Basic
Intro to C++ Basic
 
Basic Data Types in C++
Basic Data Types in C++ Basic Data Types in C++
Basic Data Types in C++
 

Similar to Minimal Introduction to C++ - Part III - Final

Minimal Introduction to C++ - Part II
Minimal Introduction to C++ - Part IIMinimal Introduction to C++ - Part II
Minimal Introduction to C++ - Part IIMichel Alves
 
Minimal Introduction to C++ - Part I
Minimal Introduction to C++ - Part IMinimal Introduction to C++ - Part I
Minimal Introduction to C++ - Part IMichel Alves
 
LocFaults, a bounded constraint-based approach to aid for error localization
LocFaults, a bounded constraint-based approach to aid for error localizationLocFaults, a bounded constraint-based approach to aid for error localization
LocFaults, a bounded constraint-based approach to aid for error localizationMohammed Bekkouche
 
c-for-c-programmers.pdf
c-for-c-programmers.pdfc-for-c-programmers.pdf
c-for-c-programmers.pdfSalar32
 
Four Languages From Forty Years Ago
Four Languages From Forty Years AgoFour Languages From Forty Years Ago
Four Languages From Forty Years AgoScott Wlaschin
 
The Miseducation of C++
The Miseducation of C++The Miseducation of C++
The Miseducation of C++Kevlin Henney
 
C prog ppt
C prog pptC prog ppt
C prog pptxinoe
 
Refactor your specs! Øredev 2013
Refactor your specs! Øredev 2013Refactor your specs! Øredev 2013
Refactor your specs! Øredev 2013Cyrille Martraire
 
Kamil witecki asynchronous, yet readable, code
Kamil witecki asynchronous, yet readable, codeKamil witecki asynchronous, yet readable, code
Kamil witecki asynchronous, yet readable, codeKamil Witecki
 
C plus plus_for_quantitative_finance
C plus plus_for_quantitative_financeC plus plus_for_quantitative_finance
C plus plus_for_quantitative_financeTomasz Waszczyk
 
C++ 11 Style : A Touch of Class
C++ 11 Style : A Touch of ClassC++ 11 Style : A Touch of Class
C++ 11 Style : A Touch of ClassYogendra Rampuria
 
Comparitive Analysis of Algorithm strategies
Comparitive Analysis of Algorithm strategiesComparitive Analysis of Algorithm strategies
Comparitive Analysis of Algorithm strategiesTalha Shaikh
 

Similar to Minimal Introduction to C++ - Part III - Final (20)

Minimal Introduction to C++ - Part II
Minimal Introduction to C++ - Part IIMinimal Introduction to C++ - Part II
Minimal Introduction to C++ - Part II
 
Minimal Introduction to C++ - Part I
Minimal Introduction to C++ - Part IMinimal Introduction to C++ - Part I
Minimal Introduction to C++ - Part I
 
tutorial.ppt
tutorial.ppttutorial.ppt
tutorial.ppt
 
Lecture1
Lecture1Lecture1
Lecture1
 
ICT C++
ICT C++ ICT C++
ICT C++
 
C Programming Homework Help
C Programming Homework HelpC Programming Homework Help
C Programming Homework Help
 
LocFaults, a bounded constraint-based approach to aid for error localization
LocFaults, a bounded constraint-based approach to aid for error localizationLocFaults, a bounded constraint-based approach to aid for error localization
LocFaults, a bounded constraint-based approach to aid for error localization
 
c-for-c-programmers.pdf
c-for-c-programmers.pdfc-for-c-programmers.pdf
c-for-c-programmers.pdf
 
DATA STRUCTURE.pdf
DATA STRUCTURE.pdfDATA STRUCTURE.pdf
DATA STRUCTURE.pdf
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURE
 
Four Languages From Forty Years Ago
Four Languages From Forty Years AgoFour Languages From Forty Years Ago
Four Languages From Forty Years Ago
 
The Miseducation of C++
The Miseducation of C++The Miseducation of C++
The Miseducation of C++
 
C prog ppt
C prog pptC prog ppt
C prog ppt
 
Refactor your specs! Øredev 2013
Refactor your specs! Øredev 2013Refactor your specs! Øredev 2013
Refactor your specs! Øredev 2013
 
Kamil witecki asynchronous, yet readable, code
Kamil witecki asynchronous, yet readable, codeKamil witecki asynchronous, yet readable, code
Kamil witecki asynchronous, yet readable, code
 
3.5
3.53.5
3.5
 
C plus plus_for_quantitative_finance
C plus plus_for_quantitative_financeC plus plus_for_quantitative_finance
C plus plus_for_quantitative_finance
 
C SLIDES PREPARED BY M V B REDDY
C SLIDES PREPARED BY  M V B REDDYC SLIDES PREPARED BY  M V B REDDY
C SLIDES PREPARED BY M V B REDDY
 
C++ 11 Style : A Touch of Class
C++ 11 Style : A Touch of ClassC++ 11 Style : A Touch of Class
C++ 11 Style : A Touch of Class
 
Comparitive Analysis of Algorithm strategies
Comparitive Analysis of Algorithm strategiesComparitive Analysis of Algorithm strategies
Comparitive Analysis of Algorithm strategies
 

More from Michel Alves

Texture Synthesis: An Approach Based on GPU Use
Texture Synthesis: An Approach Based on GPU UseTexture Synthesis: An Approach Based on GPU Use
Texture Synthesis: An Approach Based on GPU UseMichel Alves
 
Intelligent Transfer of Thematic Harmonic Color Palettes
Intelligent Transfer of Thematic Harmonic Color PalettesIntelligent Transfer of Thematic Harmonic Color Palettes
Intelligent Transfer of Thematic Harmonic Color PalettesMichel Alves
 
A Framework for Harmonic Color Measures
A Framework for Harmonic Color MeasuresA Framework for Harmonic Color Measures
A Framework for Harmonic Color MeasuresMichel Alves
 
Effectiveness of Image Quality Assessment Indexes
Effectiveness of Image Quality Assessment IndexesEffectiveness of Image Quality Assessment Indexes
Effectiveness of Image Quality Assessment IndexesMichel Alves
 
Introduction to Kernel Functions
Introduction to Kernel FunctionsIntroduction to Kernel Functions
Introduction to Kernel FunctionsMichel Alves
 
About Perception and Hue Histograms in HSV Space
About Perception and Hue Histograms in HSV SpaceAbout Perception and Hue Histograms in HSV Space
About Perception and Hue Histograms in HSV SpaceMichel Alves
 
Color Harmonization - Results
Color Harmonization - ResultsColor Harmonization - Results
Color Harmonization - ResultsMichel Alves
 
Wave Simulation Using Perlin Noise
Wave Simulation Using Perlin NoiseWave Simulation Using Perlin Noise
Wave Simulation Using Perlin NoiseMichel Alves
 
Similarity Maps Using SSIM Index
Similarity Maps Using SSIM IndexSimilarity Maps Using SSIM Index
Similarity Maps Using SSIM IndexMichel Alves
 
Qualifying Exam - Image-Based Reconstruction With Color Harmonization
Qualifying Exam - Image-Based Reconstruction With Color HarmonizationQualifying Exam - Image-Based Reconstruction With Color Harmonization
Qualifying Exam - Image-Based Reconstruction With Color HarmonizationMichel Alves
 
Month Presentations Schedule - March/2015 - LCG/UFRJ
Month Presentations Schedule - March/2015 - LCG/UFRJMonth Presentations Schedule - March/2015 - LCG/UFRJ
Month Presentations Schedule - March/2015 - LCG/UFRJMichel Alves
 
Color Palettes in R
Color Palettes in RColor Palettes in R
Color Palettes in RMichel Alves
 
Hue Wheel Prototype
Hue Wheel PrototypeHue Wheel Prototype
Hue Wheel PrototypeMichel Alves
 
Triangle Mesh Plot
Triangle Mesh PlotTriangle Mesh Plot
Triangle Mesh PlotMichel Alves
 
Capacity-Constrained Point Distributions :: Complementary Results
Capacity-Constrained Point Distributions :: Complementary ResultsCapacity-Constrained Point Distributions :: Complementary Results
Capacity-Constrained Point Distributions :: Complementary ResultsMichel Alves
 
Capacity-Constrained Point Distributions
Capacity-Constrained Point DistributionsCapacity-Constrained Point Distributions
Capacity-Constrained Point DistributionsMichel Alves
 
Five Minute Speech: An Overview of Activities Developed in Disciplines and Gu...
Five Minute Speech: An Overview of Activities Developed in Disciplines and Gu...Five Minute Speech: An Overview of Activities Developed in Disciplines and Gu...
Five Minute Speech: An Overview of Activities Developed in Disciplines and Gu...Michel Alves
 

More from Michel Alves (20)

Texture Synthesis: An Approach Based on GPU Use
Texture Synthesis: An Approach Based on GPU UseTexture Synthesis: An Approach Based on GPU Use
Texture Synthesis: An Approach Based on GPU Use
 
Intelligent Transfer of Thematic Harmonic Color Palettes
Intelligent Transfer of Thematic Harmonic Color PalettesIntelligent Transfer of Thematic Harmonic Color Palettes
Intelligent Transfer of Thematic Harmonic Color Palettes
 
A Framework for Harmonic Color Measures
A Framework for Harmonic Color MeasuresA Framework for Harmonic Color Measures
A Framework for Harmonic Color Measures
 
Effectiveness of Image Quality Assessment Indexes
Effectiveness of Image Quality Assessment IndexesEffectiveness of Image Quality Assessment Indexes
Effectiveness of Image Quality Assessment Indexes
 
Introduction to Kernel Functions
Introduction to Kernel FunctionsIntroduction to Kernel Functions
Introduction to Kernel Functions
 
About Perception and Hue Histograms in HSV Space
About Perception and Hue Histograms in HSV SpaceAbout Perception and Hue Histograms in HSV Space
About Perception and Hue Histograms in HSV Space
 
Color Harmonization - Results
Color Harmonization - ResultsColor Harmonization - Results
Color Harmonization - Results
 
Wave Simulation Using Perlin Noise
Wave Simulation Using Perlin NoiseWave Simulation Using Perlin Noise
Wave Simulation Using Perlin Noise
 
Similarity Maps Using SSIM Index
Similarity Maps Using SSIM IndexSimilarity Maps Using SSIM Index
Similarity Maps Using SSIM Index
 
Qualifying Exam - Image-Based Reconstruction With Color Harmonization
Qualifying Exam - Image-Based Reconstruction With Color HarmonizationQualifying Exam - Image-Based Reconstruction With Color Harmonization
Qualifying Exam - Image-Based Reconstruction With Color Harmonization
 
Month Presentations Schedule - March/2015 - LCG/UFRJ
Month Presentations Schedule - March/2015 - LCG/UFRJMonth Presentations Schedule - March/2015 - LCG/UFRJ
Month Presentations Schedule - March/2015 - LCG/UFRJ
 
Color Palettes in R
Color Palettes in RColor Palettes in R
Color Palettes in R
 
Sigmoid Curve Erf
Sigmoid Curve ErfSigmoid Curve Erf
Sigmoid Curve Erf
 
Hue Wheel Prototype
Hue Wheel PrototypeHue Wheel Prototype
Hue Wheel Prototype
 
Cosine Curve
Cosine CurveCosine Curve
Cosine Curve
 
Triangle Mesh Plot
Triangle Mesh PlotTriangle Mesh Plot
Triangle Mesh Plot
 
Triangle Plot
Triangle PlotTriangle Plot
Triangle Plot
 
Capacity-Constrained Point Distributions :: Complementary Results
Capacity-Constrained Point Distributions :: Complementary ResultsCapacity-Constrained Point Distributions :: Complementary Results
Capacity-Constrained Point Distributions :: Complementary Results
 
Capacity-Constrained Point Distributions
Capacity-Constrained Point DistributionsCapacity-Constrained Point Distributions
Capacity-Constrained Point Distributions
 
Five Minute Speech: An Overview of Activities Developed in Disciplines and Gu...
Five Minute Speech: An Overview of Activities Developed in Disciplines and Gu...Five Minute Speech: An Overview of Activities Developed in Disciplines and Gu...
Five Minute Speech: An Overview of Activities Developed in Disciplines and Gu...
 

Recently uploaded

Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 

Recently uploaded (20)

Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 

Minimal Introduction to C++ - Part III - Final

  • 1. Universidade Federal de Alagoas :: Campus A. C. Simões Geometric Modeling and Computer Vision Laboratory Minimal Introduction to C++ A Approach Directed to Resolution of Practical Problems Michel Alves dos Santos Universidade Federal de Alagoas, Campus A. C. Simões Tabuleiro do Martins - Maceió - AL, CEP: 57072-970 Part III - Mechanisms of Inheritance and Polymorphism {michel.mas}@gmail.com February 14, 2013 Minimal Introduction to C++ Language - Michel Alves A Approach Directed to Resolution of Pratical Problems
  • 2. Universidade Federal de Alagoas :: Campus A. C. Simões Geometric Modeling and Computer Vision Laboratory Inheritance and Polymorphism Mechanisms of Inheritance and Polymorphism What happens in this figure? Minimal Introduction to C++ Language - Michel Alves A Approach Directed to Resolution of Pratical Problems
  • 3. Universidade Federal de Alagoas :: Campus A. C. Simões Geometric Modeling and Computer Vision Laboratory What is Inheritance? The Concept of Inheritance Inheritance is a mechanism of reusing and extending existing classes without modifying them, thus producing hierarchical relationships between them. § ¤ 1 c l a s s Polygon { /∗Some code . . . ∗/ }; 2 c l a s s T r i a n g l e : p u b l i c Polygon { /∗Some code . . . ∗/ }; 3 c l a s s Rectangle : p u b l i c Polygon { /∗Some code . . . ∗/ }; ¦ ¥ Minimal Introduction to C++ Language - Michel Alves A Approach Directed to Resolution of Pratical Problems
  • 4. Universidade Federal de Alagoas :: Campus A. C. Simões Geometric Modeling and Computer Vision Laboratory What is Polymorphism? The Concept of Polymorphism Polymorphism is the ability of objects belonging to different types to respond to method, field, or property calls of the same name, each one according to an appropriate type-specific behavior. Entities that have more than one form. § ¤ 1 /∗ Example : the + ( p l u s ) o p e r a t o r i n C++∗/ 2 3 4 + 5 // i n t e g e r a d d i t i o n 4 3.14 + 2.0 // f l o a t i n g p o i n t a d d i t i o n 5 " foo " + " bar " // s t r i n g c o n c a t e n a t i o n ! 6 7 /∗ In C++, that type of polymorphism i s c a l l e d o v e r l o a d i n g ∗/ ¦ ¥ Polymorphism means that some code or operations or objects behave differently in different contexts. Minimal Introduction to C++ Language - Michel Alves A Approach Directed to Resolution of Pratical Problems
  • 5. Universidade Federal de Alagoas :: Campus A. C. Simões Geometric Modeling and Computer Vision Laboratory Inheritance and Polymorphism: Examples Some Examples of Inheritance and Polymorphism What is the importance of abstract classes? Minimal Introduction to C++ Language - Michel Alves A Approach Directed to Resolution of Pratical Problems
  • 6. Universidade Federal de Alagoas :: Campus A. C. Simões Geometric Modeling and Computer Vision Laboratory Polymorphism in C++ Types of Polymorphism in C++ • Subtype Polymorphism (Runtime Polymorphism). • Parametric Polymorphism (Compile-Time Polymorphism). • Ad-hoc Polymorphism (Overloading). • Coercion Polymorphism (Casting). Minimal Introduction to C++ Language - Michel Alves A Approach Directed to Resolution of Pratical Problems
  • 7. Universidade Federal de Alagoas :: Campus A. C. Simões Geometric Modeling and Computer Vision Laboratory Polymorphism in C++: Code Example Code Example § ¤ 1 /∗ Base c l a s s ∗/ 2 c l a s s F e l i d { p u b l i c : v i r t u a l v o i d meow( ) = 0 ; }; 3 4 /∗ S u b c l a s s e s ∗/ 5 c l a s s Cat : p u b l i c F e l i d { p u b l i c : v o i d meow( ) { cout << "meow! n" ; }}; 6 c l a s s Tiger : p u b l i c F e l i d { p u b l i c : v o i d meow( ) { cout << "MREOW! n" ; }}; 7 c l a s s Ocelot : p u b l i c F e l i d { p u b l i c : v o i d meow( ) { cout << "mews! n" ; }}; ¦ ¥ § ¤ 1 template <c l a s s T> T max(T a , T b ) { r e t u r n a > b ? a : b ;} 2 3 i n t main ( ) 4 { 5 std : : cout << max (9 , 5) << " t " << max( " foo " , " bar " ) << std : : e ndl ; // 9 foo 6 r e t u r n 0 ; 7 } ¦ ¥ § ¤ 1 3.14 + 2.0 // f l o a t i n g p o i n t a d d i t i o n 2 " foo " + " bar " // s t r i n g c o n c a t e n a t i o n ! ¦ ¥ § ¤ 1 f l o a t b = 6 ; // i n t g et s promoted ( c a s t ) to f l o a t i m p l i c i t l y 2 i n t a = 9.99 // f l o a t g et s demoted to i n t i m p l i c i t l y ¦ ¥ Minimal Introduction to C++ Language - Michel Alves A Approach Directed to Resolution of Pratical Problems
  • 8. Universidade Federal de Alagoas :: Campus A. C. Simões Geometric Modeling and Computer Vision Laboratory Solved Problems A List of Solved Problems 1 The Hierarchy of Polygon Class. • Build a system that can represent the hierarchy of polygons. The base action of this hierarchy must be area. 2 The Area of Any Function or Curve j. • Build a program that can calculate the area of any function or curve using the methods of rectangle and trapezium. Minimal Introduction to C++ Language - Michel Alves A Approach Directed to Resolution of Pratical Problems
  • 9. Universidade Federal de Alagoas :: Campus A. C. Simões Geometric Modeling and Computer Vision Laboratory Exercises to Home • Problem: The Hierarchy of Sorting Algorithms • Build a minimal system that can represent the hierarchy of sorting algorithms considering ours complexity. • Algorithms that must be implemented: bubble, insertion, quick and merge. • Polyhedron Representation • Build a minimal system that can represent regular polyhedrons. The base class Polyhedron must has the follow methods: • is_regular, area, volume, edge_length. Minimal Introduction to C++ Language - Michel Alves A Approach Directed to Resolution of Pratical Problems
  • 10. Universidade Federal de Alagoas :: Campus A. C. Simões Geometric Modeling and Computer Vision Laboratory Thanks Thanks for your attention! Michel Alves dos Santos - michel.mas@gmail.com Minimal Introduction to C++ Language - Michel Alves A Approach Directed to Resolution of Pratical Problems