This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
in204:tds:sujets:td5:part1 [2019/11/13 12:40] bmonsuez [Question n°2.3] |
in204:tds:sujets:td5:part1 [2022/11/18 10:48] (current) |
||
---|---|---|---|
Line 30: | Line 30: | ||
<hidden Correction> | <hidden Correction> | ||
+ | <nodisp 2> | ||
Pour convertir un nombre en virgule flottante en un nombre complexe, il faut définir de [[in204:cpp:syntax:class:constructor|nouveaux constructeurs]] qui vont prendre un seul argument qui aura pour type le type d'un nombre à virgule flottante. | Pour convertir un nombre en virgule flottante en un nombre complexe, il faut définir de [[in204:cpp:syntax:class:constructor|nouveaux constructeurs]] qui vont prendre un seul argument qui aura pour type le type d'un nombre à virgule flottante. | ||
Line 63: | Line 64: | ||
}; | }; | ||
</code> | </code> | ||
- | |||
</hidden> | </hidden> | ||
==== Question n°1.2===== | ==== Question n°1.2===== | ||
Line 94: | Line 94: | ||
}; | }; | ||
</code> | </code> | ||
- | |||
</hidden> | </hidden> | ||
==== Question n°1.3===== | ==== Question n°1.3===== | ||
Line 187: | Line 186: | ||
Complex complexB(Polar(), 1.0, 0,52); | Complex complexB(Polar(), 1.0, 0,52); | ||
</code> | </code> | ||
- | |||
</hidden> | </hidden> | ||
Line 268: | Line 266: | ||
</code> | </code> | ||
- | |||
</hidden> | </hidden> | ||
Line 317: | Line 314: | ||
} | } | ||
</code> | </code> | ||
- | |||
</hidden> | </hidden> | ||
Line 352: | Line 348: | ||
} | } | ||
</code> | </code> | ||
- | |||
</hidden> | </hidden> | ||
==== Question n°2.2==== | ==== Question n°2.2==== | ||
Line 366: | Line 361: | ||
<hidden Correction> | <hidden Correction> | ||
- | |||
<code cpp> | <code cpp> | ||
class Complex | class Complex | ||
Line 423: | Line 417: | ||
</code> | </code> | ||
+ | |||
</hidden> | </hidden> | ||
Line 481: | Line 476: | ||
<hidden Correction> | <hidden Correction> | ||
+ | <code cpp> | ||
Complex operator * (const Complex& aRightValue) const | Complex operator * (const Complex& aRightValue) const | ||
{ | { | ||
Line 496: | Line 491: | ||
- aRightValue.mImaginaryPart / squareNorm); | - aRightValue.mImaginaryPart / squareNorm); | ||
} | } | ||
+ | |||
+ | </code> | ||
</hidden> | </hidden> | ||
+ | |||
==== Question n°3.3 (optionnel) ==== | ==== Question n°3.3 (optionnel) ==== | ||
- | Proposer une surcharge des opérations + et –. Implanter ces dernières et tester. | + | Proposer une surcharge des opérations '*=' et '/='. Implanter ces dernières et tester. |
<code cpp> | <code cpp> |