SlideShare uma empresa Scribd logo
1 de 28
Inheritance Concept class Rectangle{   private:   int numVertices;   float *xCoord, *yCoord;   public:   void set(float *x, float *y, int nV);   float area(); }; Rectangle Triangle Polygon class Polygon{   private: int numVertices; float *xCoord, *yCoord;   public: void set(float *x, float *y, int nV); }; class Triangle{   private:   int numVertices; float *xCoord, *yCoord;   public: void set(float *x, float *y, int nV);   float area(); };
Inheritance Concept Rectangle Triangle Polygon class Polygon{ protected:   int numVertices;   float *xCoord, float *yCoord; public:   void set(float *x, float *y, int nV); }; class Rectangle : public Polygon{ public:     float  area(); }; class Rectangle{ protected:   int numVertices;   float *xCoord, float *yCoord; public:   void set(float *x, float *y, int nV);   float area(); };
Inheritance Concept Rectangle Triangle Polygon class Polygon{ protected:   int numVertices;   float *xCoord, float *yCoord; public:   void set(float *x, float *y, int nV); }; class Triangle : public Polygon{ public:   float area(); }; class Triangle{ protected:   int numVertices;   float *xCoord, float *yCoord; public:   void set(float *x, float *y, int nV);   float area(); };
Inheritance Concept Point Circle 3D-Point class Point{ protected:   int x, y; public:   void set (int a, int b); }; class Circle : public Point{ private:  double r; }; class 3D-Point: public Point{ private:  int z; }; x y x y r x y z
[object Object],[object Object],Inheritance Concept RealNumber ComplexNumber ImaginaryNumber Rectangle Triangle Polygon Point Circle real imag real imag 3D-Point
Why Inheritance ? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Define a Class Hierarchy ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Class Derivation Point 3D-Point class Point{ protected:   int x, y; public:   void set (int a, int b); }; class 3D-Point : public Point{ private:  double z; … … }; class Sphere : public 3D-Point{ private:  double r; … … }; Sphere Point  is the base class of  3D-Point , while  3D-Point  is the base class of  Sphere
What to inherit? ,[object Object],[object Object]
Access Control Over the Members ,[object Object],[object Object],[object Object],class Point{ protected:  int x, y; public:  void set(int a, int b); }; class Circle :  public  Point{ … … };
[object Object],Access Rights of Derived Classes Type of Inheritance Access Control for Members public protected private public protected protected private protected - - - private public protected private
Class Derivation class daughter :  ---------  mother{ private: double dPriv; public: void mFoo ( ); }; class mother{ protected:  int mProc; public:  int mPubl; private:  int  mPriv; }; class daughter :  ---------  mother{ private: double dPriv; public: void dFoo ( ); }; void daughter :: dFoo ( ){ mPriv = 10;   //error mProc = 20; }; private/protected/public int main() { /*….*/ } class grandDaughter :  public  daughter { private: double gPriv; public: void gFoo ( ); };
What to inherit? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Constructor Rules for Derived Classes  ,[object Object],class A { public: A ( )   {cout<< “A:default”<<endl;} A (int a)   {cout<<“A:parameter”<<endl;} }; class B : public A  { public:  B (int a)   {cout<<“B”<<endl;} }; B test(1); A:default B output:
Constructor Rules for Derived Classes  ,[object Object],class A { public: A ( )   {cout<< “A:default”<<endl;} A (int a)   {cout<<“A:parameter”<<endl;} }; class C : public A { public:  C (int a) : A(a)   {cout<<“C”<<endl;} }; C test(1); A:parameter C output: ,[object Object],[object Object]
Define its Own Members Point Circle class Point{ protected:   int x, y; public:   void set(int a, int b); }; class Circle : public Point{ private:  double r; public: void set_r(double c); }; x y x y r class Circle{ protected:   int x, y; private:   double r; public:   void set(int a, int b);   void set_r(double c); }; The derived class can also define its own members,  in addition to the members inherited from the base class
Even more … ,[object Object],[object Object],[object Object],class A { protected: int x, y; public: void print () {cout<<“From A”<<endl;} }; class B : public A { public:  void print ()   {cout<<“From B”<<endl;} };
class Point{ protected:   int x, y; public:   void  set (int a, int b) {x=a; y=b;}   void  foo  ();   void  print (); }; class Circle : public Point{ private:  double r; public: void  set  (int a, int b, double c) {   Point :: set(a, b);  //same name function call   r = c; } void  print ();  }; Access a Method Circle C; C. set (10,10,100);  // from class Circle C. foo  ();  // from base class Point C. print (); // from class Circle Point A; A. set (30,50);  // from base class Point A. print ();  // from base class Point
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Putting Them Together ExtTime Time
class   Time  Specification ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],// SPECIFICATION  FILE  ( time.h)
Class Interface Diagram Protected data: hrs mins secs Set Increment Write Time Time Time   class
Derived Class  ExtTime   ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Class Interface Diagram Protected data: hrs mins secs ExtTime   class Set Increment Write Time Time Set Increment Write ExtTime ExtTime Private data: zone
Implementation of  ExtTime ,[object Object],[object Object],[object Object],[object Object],Default Constructor The default constructor of base class, Time(), is automatically called, when an ExtTime object is created. ExtTime et1; hrs = 0 mins = 0 secs = 0 zone = EST et1
Implementation of  ExtTime ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Another Constructor ExtTime *et2 =  new ExtTime(8,30,0,EST); hrs = 8 mins = 30 secs = 0 zone = EST et2 5000 ??? 6000 5000
Implementation of  ExtTime ,[object Object],[object Object],[object Object],[object Object],[object Object],void  ExtTime :: Write ( )  const  // function overriding { string  zoneString[8] =  {“EST”, “CST”, MST”, “PST”, “EDT”, “CDT”, “MDT”, “PDT”} ; Time :: Write ( ) ; cout  <<‘  ‘<<zoneString[zone]<<endl; }
Working with   ExtTime ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Take Home Message ,[object Object],[object Object]

Mais conteúdo relacionado

Mais procurados

Virtual function
Virtual functionVirtual function
Virtual functionharman kaur
 
Objective-Cひとめぐり
Objective-CひとめぐりObjective-Cひとめぐり
Objective-CひとめぐりKenji Kinukawa
 
Multiple inheritance in c++
Multiple inheritance in c++Multiple inheritance in c++
Multiple inheritance in c++Saket Pathak
 
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)PROIDEA
 
Decorated Attribute Grammars (CC 2009)
Decorated Attribute Grammars (CC 2009)Decorated Attribute Grammars (CC 2009)
Decorated Attribute Grammars (CC 2009)lennartkats
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorJussi Pohjolainen
 
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)changehee lee
 
20.2 Java inheritance
20.2 Java inheritance20.2 Java inheritance
20.2 Java inheritanceIntro C# Book
 
Roberto Gallea: Workshop Arduino, giorno #2 Arduino + Processing
Roberto Gallea: Workshop Arduino, giorno #2 Arduino + ProcessingRoberto Gallea: Workshop Arduino, giorno #2 Arduino + Processing
Roberto Gallea: Workshop Arduino, giorno #2 Arduino + ProcessingDemetrio Siragusa
 
11. Objects and Classes
11. Objects and Classes11. Objects and Classes
11. Objects and ClassesIntro C# Book
 
Code as data as code.
Code as data as code.Code as data as code.
Code as data as code.Mike Fogus
 
11. Java Objects and classes
11. Java  Objects and classes11. Java  Objects and classes
11. Java Objects and classesIntro C# Book
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionHans Höchtl
 
Exhibition of Atrocity
Exhibition of AtrocityExhibition of Atrocity
Exhibition of AtrocityMichael Pirnat
 
from java to c
from java to cfrom java to c
from java to cVõ Hòa
 

Mais procurados (20)

ddd+scala
ddd+scaladdd+scala
ddd+scala
 
Virtual function
Virtual functionVirtual function
Virtual function
 
Objective-Cひとめぐり
Objective-CひとめぐりObjective-Cひとめぐり
Objective-Cひとめぐり
 
Multiple inheritance in c++
Multiple inheritance in c++Multiple inheritance in c++
Multiple inheritance in c++
 
Constructors & destructors
Constructors & destructorsConstructors & destructors
Constructors & destructors
 
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
 
C++ L09-Classes Part2
C++ L09-Classes Part2C++ L09-Classes Part2
C++ L09-Classes Part2
 
Decorated Attribute Grammars (CC 2009)
Decorated Attribute Grammars (CC 2009)Decorated Attribute Grammars (CC 2009)
Decorated Attribute Grammars (CC 2009)
 
SDC - Einführung in Scala
SDC - Einführung in ScalaSDC - Einführung in Scala
SDC - Einführung in Scala
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operator
 
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)
 
20.2 Java inheritance
20.2 Java inheritance20.2 Java inheritance
20.2 Java inheritance
 
Roberto Gallea: Workshop Arduino, giorno #2 Arduino + Processing
Roberto Gallea: Workshop Arduino, giorno #2 Arduino + ProcessingRoberto Gallea: Workshop Arduino, giorno #2 Arduino + Processing
Roberto Gallea: Workshop Arduino, giorno #2 Arduino + Processing
 
11. Objects and Classes
11. Objects and Classes11. Objects and Classes
11. Objects and Classes
 
Code as data as code.
Code as data as code.Code as data as code.
Code as data as code.
 
11. Java Objects and classes
11. Java  Objects and classes11. Java  Objects and classes
11. Java Objects and classes
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
Object calisthenics
Object calisthenicsObject calisthenics
Object calisthenics
 
Exhibition of Atrocity
Exhibition of AtrocityExhibition of Atrocity
Exhibition of Atrocity
 
from java to c
from java to cfrom java to c
from java to c
 

Destaque

Mahadi The role of indigenous gums and resins in pastoralist livelihood secur...
Mahadi The role of indigenous gums and resins in pastoralist livelihood secur...Mahadi The role of indigenous gums and resins in pastoralist livelihood secur...
Mahadi The role of indigenous gums and resins in pastoralist livelihood secur...futureagricultures
 
CLIMATE CHANGE IMPLICATIONS ON FOOD AND AGRICUTURE IN AFRICA
CLIMATE CHANGE IMPLICATIONS ON FOOD AND AGRICUTURE IN AFRICACLIMATE CHANGE IMPLICATIONS ON FOOD AND AGRICUTURE IN AFRICA
CLIMATE CHANGE IMPLICATIONS ON FOOD AND AGRICUTURE IN AFRICARUFORUM
 
день героев отечества
день героев отечествадень героев отечества
день героев отечестваelvira38
 
Q 4 week 2
Q 4 week 2Q 4 week 2
Q 4 week 2Les Davy
 
Household items for sport
Household items for sportHousehold items for sport
Household items for sportCecilia Aguilar
 
Asthma Presentation
Asthma PresentationAsthma Presentation
Asthma PresentationAC Tambago
 
Researchers - recommendations from AIGLIA2014
Researchers - recommendations from AIGLIA2014Researchers - recommendations from AIGLIA2014
Researchers - recommendations from AIGLIA2014futureagricultures
 
Assessing enablers and constrainers of graduation
Assessing enablers and constrainers of graduationAssessing enablers and constrainers of graduation
Assessing enablers and constrainers of graduationfutureagricultures
 
Evaluation Question 4
Evaluation Question 4Evaluation Question 4
Evaluation Question 4Sammi Wilde
 

Destaque (20)

Mahadi The role of indigenous gums and resins in pastoralist livelihood secur...
Mahadi The role of indigenous gums and resins in pastoralist livelihood secur...Mahadi The role of indigenous gums and resins in pastoralist livelihood secur...
Mahadi The role of indigenous gums and resins in pastoralist livelihood secur...
 
CLIMATE CHANGE IMPLICATIONS ON FOOD AND AGRICUTURE IN AFRICA
CLIMATE CHANGE IMPLICATIONS ON FOOD AND AGRICUTURE IN AFRICACLIMATE CHANGE IMPLICATIONS ON FOOD AND AGRICUTURE IN AFRICA
CLIMATE CHANGE IMPLICATIONS ON FOOD AND AGRICUTURE IN AFRICA
 
Comicus-Markedsføring-2015
Comicus-Markedsføring-2015Comicus-Markedsføring-2015
Comicus-Markedsføring-2015
 
1 21
1 211 21
1 21
 
World I: Module 6
World I: Module 6World I: Module 6
World I: Module 6
 
день героев отечества
день героев отечествадень героев отечества
день героев отечества
 
Q 4 week 2
Q 4 week 2Q 4 week 2
Q 4 week 2
 
Household items for sport
Household items for sportHousehold items for sport
Household items for sport
 
Agenda robert guzman
Agenda robert guzmanAgenda robert guzman
Agenda robert guzman
 
affTA02 - BAB II
affTA02 - BAB IIaffTA02 - BAB II
affTA02 - BAB II
 
Asthma Presentation
Asthma PresentationAsthma Presentation
Asthma Presentation
 
Oap
OapOap
Oap
 
Researchers - recommendations from AIGLIA2014
Researchers - recommendations from AIGLIA2014Researchers - recommendations from AIGLIA2014
Researchers - recommendations from AIGLIA2014
 
Assessing enablers and constrainers of graduation
Assessing enablers and constrainers of graduationAssessing enablers and constrainers of graduation
Assessing enablers and constrainers of graduation
 
Destroying property
Destroying propertyDestroying property
Destroying property
 
Hyperactivity
HyperactivityHyperactivity
Hyperactivity
 
Fighting cleanup routines
Fighting cleanup routinesFighting cleanup routines
Fighting cleanup routines
 
Xavier thoma
Xavier thomaXavier thoma
Xavier thoma
 
Evaluation Question 4
Evaluation Question 4Evaluation Question 4
Evaluation Question 4
 
01 05-14
01 05-1401 05-14
01 05-14
 

Semelhante a Lecture4

Semelhante a Lecture4 (20)

Inheritance.pptx
Inheritance.pptxInheritance.pptx
Inheritance.pptx
 
14. Defining Classes
14. Defining Classes14. Defining Classes
14. Defining Classes
 
inhertance c++
inhertance c++inhertance c++
inhertance c++
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance in C++.ppt
Inheritance in C++.pptInheritance in C++.ppt
Inheritance in C++.ppt
 
C++ Language
C++ LanguageC++ Language
C++ Language
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorials
 
C# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewC# 6.0 - April 2014 preview
C# 6.0 - April 2014 preview
 
Basics of objective c
Basics of objective cBasics of objective c
Basics of objective c
 
c++-language-1208539706757125-9.pdf
c++-language-1208539706757125-9.pdfc++-language-1208539706757125-9.pdf
c++-language-1208539706757125-9.pdf
 
Chapter27 polymorphism-virtual-function-abstract-class
Chapter27 polymorphism-virtual-function-abstract-classChapter27 polymorphism-virtual-function-abstract-class
Chapter27 polymorphism-virtual-function-abstract-class
 
Object-oriented Basics
Object-oriented BasicsObject-oriented Basics
Object-oriented Basics
 
Lab3
Lab3Lab3
Lab3
 
Inheritance
InheritanceInheritance
Inheritance
 
OOP Lab Report.docx
OOP Lab Report.docxOOP Lab Report.docx
OOP Lab Report.docx
 
Defining classes-and-objects-1.0
Defining classes-and-objects-1.0Defining classes-and-objects-1.0
Defining classes-and-objects-1.0
 
Review constdestr
Review constdestrReview constdestr
Review constdestr
 
inheritance c++
inheritance c++inheritance c++
inheritance c++
 

Mais de FALLEE31188 (20)

Lecture2
Lecture2Lecture2
Lecture2
 
L16
L16L16
L16
 
L2
L2L2
L2
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
Functions
FunctionsFunctions
Functions
 
Field name
Field nameField name
Field name
 
Encapsulation
EncapsulationEncapsulation
Encapsulation
 
Cpp tutorial
Cpp tutorialCpp tutorial
Cpp tutorial
 
Cis068 08
Cis068 08Cis068 08
Cis068 08
 
Chapter14
Chapter14Chapter14
Chapter14
 
Chapt03
Chapt03Chapt03
Chapt03
 
C++lecture9
C++lecture9C++lecture9
C++lecture9
 
C++ polymorphism
C++ polymorphismC++ polymorphism
C++ polymorphism
 
C1320prespost
C1320prespostC1320prespost
C1320prespost
 
Brookshear 06
Brookshear 06Brookshear 06
Brookshear 06
 
Book ppt
Book pptBook ppt
Book ppt
 
Assignment 2
Assignment 2Assignment 2
Assignment 2
 
Assignment
AssignmentAssignment
Assignment
 
5 2
5 25 2
5 2
 

Último

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
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
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
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
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
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
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
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 

Último (20)

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
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
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
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
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
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
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
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 

Lecture4

  • 1. Inheritance Concept class Rectangle{ private: int numVertices; float *xCoord, *yCoord; public: void set(float *x, float *y, int nV); float area(); }; Rectangle Triangle Polygon class Polygon{ private: int numVertices; float *xCoord, *yCoord; public: void set(float *x, float *y, int nV); }; class Triangle{ private: int numVertices; float *xCoord, *yCoord; public: void set(float *x, float *y, int nV); float area(); };
  • 2. Inheritance Concept Rectangle Triangle Polygon class Polygon{ protected: int numVertices; float *xCoord, float *yCoord; public: void set(float *x, float *y, int nV); }; class Rectangle : public Polygon{ public: float area(); }; class Rectangle{ protected: int numVertices; float *xCoord, float *yCoord; public: void set(float *x, float *y, int nV); float area(); };
  • 3. Inheritance Concept Rectangle Triangle Polygon class Polygon{ protected: int numVertices; float *xCoord, float *yCoord; public: void set(float *x, float *y, int nV); }; class Triangle : public Polygon{ public: float area(); }; class Triangle{ protected: int numVertices; float *xCoord, float *yCoord; public: void set(float *x, float *y, int nV); float area(); };
  • 4. Inheritance Concept Point Circle 3D-Point class Point{ protected: int x, y; public: void set (int a, int b); }; class Circle : public Point{ private: double r; }; class 3D-Point: public Point{ private: int z; }; x y x y r x y z
  • 5.
  • 6.
  • 7.
  • 8. Class Derivation Point 3D-Point class Point{ protected: int x, y; public: void set (int a, int b); }; class 3D-Point : public Point{ private: double z; … … }; class Sphere : public 3D-Point{ private: double r; … … }; Sphere Point is the base class of 3D-Point , while 3D-Point is the base class of Sphere
  • 9.
  • 10.
  • 11.
  • 12. Class Derivation class daughter : --------- mother{ private: double dPriv; public: void mFoo ( ); }; class mother{ protected: int mProc; public: int mPubl; private: int mPriv; }; class daughter : --------- mother{ private: double dPriv; public: void dFoo ( ); }; void daughter :: dFoo ( ){ mPriv = 10; //error mProc = 20; }; private/protected/public int main() { /*….*/ } class grandDaughter : public daughter { private: double gPriv; public: void gFoo ( ); };
  • 13.
  • 14.
  • 15.
  • 16. Define its Own Members Point Circle class Point{ protected: int x, y; public: void set(int a, int b); }; class Circle : public Point{ private: double r; public: void set_r(double c); }; x y x y r class Circle{ protected: int x, y; private: double r; public: void set(int a, int b); void set_r(double c); }; The derived class can also define its own members, in addition to the members inherited from the base class
  • 17.
  • 18. class Point{ protected: int x, y; public: void set (int a, int b) {x=a; y=b;} void foo (); void print (); }; class Circle : public Point{ private: double r; public: void set (int a, int b, double c) { Point :: set(a, b); //same name function call r = c; } void print (); }; Access a Method Circle C; C. set (10,10,100); // from class Circle C. foo (); // from base class Point C. print (); // from class Circle Point A; A. set (30,50); // from base class Point A. print (); // from base class Point
  • 19.
  • 20.
  • 21. Class Interface Diagram Protected data: hrs mins secs Set Increment Write Time Time Time class
  • 22.
  • 23. Class Interface Diagram Protected data: hrs mins secs ExtTime class Set Increment Write Time Time Set Increment Write ExtTime ExtTime Private data: zone
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.