Cours de C++  - Héritage
27 pages
English
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres
27 pages
English
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres

Description

CoursdeC++HéritageCécile Braunsteincecile.braunstein@lip6.frCours de C++ 1 / 21BasiccasesAwidthC BCours de C++ 2 / 21sideheightradiusBasiccasesAwidthC BSquare Rectangle Circle Triangle_center _center _center _center_side _width _radius _pointAGetCenter() _height GetCenter() _pointBDraw() GetCenter() Draw() _pointCErase() Draw() Erase() GetCenter()Erase() Draw()Erase()Cours de C++ 2 / 21sideheightradiusLookmorecloserSquare Rectangle Circle Triangle_center _center _center _center_side _width _radius _pointAGetCenter() _height GetCenter() _pointBDraw() GetCenter() Draw() _pointCErase() Draw() Erase() GetCenter()Erase() Draw()Erase()Cours de C++ 3 / 21LookmorecloserSquare Rectangle Circle Triangle_center _center _center _center_side _width _radius _pointAGetCenter() _height GetCenter() _pointBDraw() GetCenter() Draw() _pointCErase() Draw() Erase() GetCenter()Erase() Draw()Erase()Cours de C++ 3 / 21LookmorecloserSquare Rectangle Circle Triangle_center _center _center _center_side _width _radius _pointAGetCenter() _height GetCenter() _pointBDraw() GetCenter() Draw() _pointCErase() Draw() Erase() GetCenter()Erase() Draw()Erase()Cours de C++ 3 / 21ClasshierarchyFigure_centerGetCenter()Draw()Erase()Polygon_Draw()Square Rectangle Circle Triangle_side _width _radius _pointADraw() _height Draw() _pointBDraw() _pointCDraw()Cours de C++ 4 / 21Protectionrevisitedclass Figure {private :Point _center;public ...

Informations

Publié par
Nombre de lectures 18
Langue English

Extrait

Cours de C++
Cours
de
C++
Héritage
Cécile Braunstein cecile.braunstein@lip6.fr
1 /
21
Basic
Cours
de
C++
cases
2
/
21
Basic
Cours
de
C++
cases
2
/
21
Look
Cours
de
more
C++
closer
3
/
21
Look
Cours
de
more
C++
closer
3
/
21
Look
Cours
de
more
C++
closer
3
/
21
Class
Cours
de
C++
hierarchy
4
/
21
Protection revisited
classFigure { private: Point center; _
public: Figure(Point& center);
Point& GetCenter(); voidDraw(); voidErase();
};
Cours de C++
5/21
Protection revisited
classFigure { protected: Point _center;
public: Figure(Point& center);
Point& GetCenter(); voidDraw(); voidErase();
};
Cours de C++
5/21
More about protection
LetBandCbe two classes such thatCderived fromBpublicaly.
privateandpublic privatemembers ofB: Only classBmay access to these members publicmembers ofB: Everyone may access to these members
protected BandChave access to these members They are still part of the interface Users of classCcan not have direct access to these members
Coursed+C+6/12
Composition of protection
3 types of inheritance public: Like the definition of a sub-type. privateorprotected: Hide details of the implementation
Change access to the class members
oCrused+C+
Members of the base class public protected private
public
protected
private
protected
protected
private
no access
no access
no access
7/21
  • Univers Univers
  • Ebooks Ebooks
  • Livres audio Livres audio
  • Presse Presse
  • Podcasts Podcasts
  • BD BD
  • Documents Documents