This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
in202:seance_2:td_2:part_iv [2021/03/28 12:42] bmonsuez created |
in202:seance_2:td_2:part_iv [2022/11/18 10:45] (current) |
||
|---|---|---|---|
| Line 18: | Line 18: | ||
| <code cpp> | <code cpp> | ||
| - | void testFamilyOfCounters() | + | |
| + | void testCounter(BaseCounter& aCounter) | ||
| { | { | ||
| - | ForwardCounter incCounter(0, 4); | ||
| - | BackwardCounter decCounter(0, 3); | ||
| for(int i=0; i < 6; i++) | for(int i=0; i < 6; i++) | ||
| { | { | ||
| - | incCounter.next(); | + | aCounter.next(); |
| - | incCounter.print(); | + | aCounter.print(); |
| - | decCounter.next(); | + | |
| - | decCounter.print(); | + | |
| } | } | ||
| + | } | ||
| + | |||
| + | void testFamilyOfCounters() | ||
| + | { | ||
| + | ForwardCounter incCounter(0, 4); | ||
| + | BackwardCounter decCounter(3, 5); | ||
| + | testCounter(incCounter); | ||
| + | testCounter(decCounter); | ||
| } | } | ||
| </code> | </code> | ||
| + | |||
| + | |||
| + | ===== Ressources ===== | ||
| + | |||
| + | ==== Code présenté pendant le cours ==== | ||
| + | |||
| + | {{https://perso.ensta-paris.fr/~bmonsuez/Media/code/in202/2021/td2/part4/part4.cpp|''part4.cpp''}} Fichier principal contient les fonctions de test et le main. | ||
| + | |||
| + | {{https://perso.ensta-paris.fr/~bmonsuez/Media/code/in202/2021/td2/part4/BaseCounter.hpp|''BaseCounter.hpp''}} Définition de la classe de base ''BaseCounter''. | ||
| + | |||
| + | {{https://perso.ensta-paris.fr/~bmonsuez/Media/code/in202/2021/td2/part4/ForwardCounter.hpp|''ForwardCounter.hpp''}} Définition des classes ''ForwardCounter'' et ''BackwardCounter''. | ||
| + | |||
| + | ==== Liens vers les éléments syntaxiques C++ ==== | ||
| + | |||
| + | [[cpp:syntax:class:deriving|Héritage & Dérivation de classe]] | ||
| + | |||
| + | [[cpp:syntax:class:deriving:constructor|Contructeurs dans les classes dérivées]] | ||
| + | |||
| + | [[cpp:syntax:class:deriving:methods|Méthodes dans les classe dérivées]] | ||
| + | |||
| + | [[cpp:syntax:class:deriving:virtual_methods|Méthodes virtuelles]] | ||
| + | |||
| + | ===== Navigation ===== | ||
| [[.:part_iii|Troisième partie]] | [[.:part_iii|Troisième partie]] | ||