This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
in204:tds:sujets:td1:part2 [2019/09/23 16:13] bmonsuez [Question n° 3] |
in204:tds:sujets:td1:part2 [2022/11/18 10:50] (current) |
||
---|---|---|---|
Line 139: | Line 139: | ||
Proposer enfin un constructeur de recopie qui permet de créer un nouveau compteur étant la copie d’un compteur passé en paramètre. | Proposer enfin un constructeur de recopie qui permet de créer un nouveau compteur étant la copie d’un compteur passé en paramètre. | ||
- | + | ||
+ | <hidden Correction> | ||
+ | |||
+ | Le constructeur de recopie se définit simplement comme suit : | ||
+ | |||
+ | <code cpp> | ||
+ | struct MyCounter | ||
+ | { | ||
+ | MyCounter(const MyCounter& anotherCounter): | ||
+ | counter(anotherCounter.counter), | ||
+ | max(anotherCounter.max) | ||
+ | {} | ||
+ | }; | ||
+ | </code> | ||
+ | |||
+ | </hidden> | ||