diff --git a/1-ProceduralProgramming/6b-hands-on.ipynb b/1-ProceduralProgramming/6b-hands-on.ipynb index 061a21ca60cdb65ffe2d7df37e3544d4bc6dc68e..6b1e441ad7c1f1e8f4db7ae8c7afd4c727ee8a2a 100644 --- a/1-ProceduralProgramming/6b-hands-on.ipynb +++ b/1-ProceduralProgramming/6b-hands-on.ipynb @@ -14,7 +14,7 @@ }, "source": [ "<h1>Table of contents<span class=\"tocSkip\"></span></h1>\n", - "<div class=\"toc\"><ul class=\"toc-item\"><li><span><a href=\"#EXERCICE-8:-Multiplication-by-an-integer\" data-toc-modified-id=\"EXERCICE-8:-Multiplication-by-an-integer-1\"><strong>EXERCICE 8: Multiplication by an integer</strong></a></span></li><li><span><a href=\"#EXERCICE-9:-display-sum-of-two-Multiply\" data-toc-modified-id=\"EXERCICE-9:-display-sum-of-two-Multiply-2\">EXERCICE 9: display sum of two <code>Multiply</code></a></span></li><li><span><a href=\"#EXERCICE-10:-print-error-in-DisplaySumOfMultiply()\" data-toc-modified-id=\"EXERCICE-10:-print-error-in-DisplaySumOfMultiply()-3\"><strong>EXERCICE 10: print error in <code>DisplaySumOfMultiply()</code></strong></a></span></li><li><span><a href=\"#[optional]-EXERCICE-11:-function-pointers\" data-toc-modified-id=\"[optional]-EXERCICE-11:-function-pointers-4\">[optional] EXERCICE 11: function pointers</a></span></li><li><span><a href=\"#[optional]-EXERCICE-12:-write-in-output-file\" data-toc-modified-id=\"[optional]-EXERCICE-12:-write-in-output-file-5\">[optional] EXERCICE 12: write in output file</a></span></li></ul></div>" + "<div class=\"toc\"><ul class=\"toc-item\"><li><span><a href=\"#EXERCICE-8:-Multiplication-by-an-integer\" data-toc-modified-id=\"EXERCICE-8:-Multiplication-by-an-integer-1\"><strong>EXERCICE 8: Multiplication by an integer</strong></a></span></li><li><span><a href=\"#EXERCICE-9:-display-sum-of-two-Multiply\" data-toc-modified-id=\"EXERCICE-9:-display-sum-of-two-Multiply-2\">EXERCICE 9: display sum of two Multiply</a></span></li><li><span><a href=\"#EXERCICE-10:-print-error-in-DisplaySumOfMultiply()\" data-toc-modified-id=\"EXERCICE-10:-print-error-in-DisplaySumOfMultiply()-3\"><strong>EXERCICE 10: print error in <code>DisplaySumOfMultiply()</code></strong></a></span></li><li><span><a href=\"#[optional]-EXERCICE-11:-function-pointers\" data-toc-modified-id=\"[optional]-EXERCICE-11:-function-pointers-4\">[optional] EXERCICE 11: function pointers</a></span></li><li><span><a href=\"#[optional]-EXERCICE-12:-write-in-output-file\" data-toc-modified-id=\"[optional]-EXERCICE-12:-write-in-output-file-5\">[optional] EXERCICE 12: write in output file</a></span></li></ul></div>" ] }, { @@ -98,7 +98,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### EXERCICE 9: display sum of two `Multiply`\n", + "### EXERCICE 9: display sum of two Multiply\n", "\n", "Write a `DisplaySumOfMultiply` function which will write the computation of the sum of two real numbers through their approximation.\n", "\n", @@ -219,26 +219,26 @@ "metadata": {}, "outputs": [], "source": [ - "void Display065(int nbits)\n", + "void Display_065(int nbits)\n", "{ \n", " DisplayPowerOf2Approx(nbits, 0.65); \n", "}\n", "\n", - "void Display035(int nbits)\n", + "void Display_035(int nbits)\n", "{\n", " DisplayPowerOf2Approx(nbits, 0.35); \n", "}\n", "\n", - "void Display065_3515_035_4832(int nbits)\n", + "void Display_065_3515_035_4832(int nbits)\n", "{ \n", " DisplaySumOfMultiply(nbits, 0.65, 3515, 0.35, 4832); \n", "}\n", "\n", "int main()\n", "{\n", - " Loop(2, 8, 2, Display065);\n", - " Loop(2, 8, 2, Display035);\n", - " Loop(1, 8, 1, Display065_3515_035_4832);\n", + " Loop(2, 8, 2, Display_065);\n", + " Loop(2, 8, 2, Display_035);\n", + " Loop(1, 8, 1, Display_065_3515_035_4832);\n", " return EXIT_SUCCESS;\n", "}\n" ] @@ -249,7 +249,7 @@ "source": [ "### [optional] EXERCICE 12: write in output file \n", "\n", - "Modify the program so that the `displayXXX` functions take an additional argument: the output stream to which the content should be written. `Loop()` will be modified as well.\n", + "Modify the program so that the `DisplayXXX` functions take an additional argument: the output stream to which the content should be written. `Loop()` will be modified as well.\n", "\n", "The following `main()` which writes part of the outputs in a file should work:" ] @@ -274,9 +274,9 @@ " // Open the stream to the file.\n", " std::ofstream output_file(argv[1]);\n", " \n", - " Loop(output_file, 2, 8, 2, Display065);\n", - " Loop(output_file, 2, 8, 2, Display035);\n", - " Loop(std::cout, 1, 8, 1, Display065_3515_035_4832);\n", + " Loop(output_file, 2, 8, 2, Display_065);\n", + " Loop(output_file, 2, 8, 2, Display_035);\n", + " Loop(std::cout, 1, 8, 1, Display_065_3515_035_4832);\n", "\n", " return EXIT_SUCCESS;\n", "}" diff --git a/HandsOn/1-ProceduralProgramming/Solution/exercice12.cpp b/HandsOn/1-ProceduralProgramming/Solution/exercice12.cpp index ec05e019d5c4d3e97669c45ef6d3ca78b4685857..d0113e6bdc5a41fab8eb870a97bb7ef8e1e19c90 100644 --- a/HandsOn/1-ProceduralProgramming/Solution/exercice12.cpp +++ b/HandsOn/1-ProceduralProgramming/Solution/exercice12.cpp @@ -110,17 +110,17 @@ void DisplaySumOfMultiply(std::ostream& out, int Nbits, double value1, int coeff } -void Display065(std::ostream& out, int Nbits) +void Display_065(std::ostream& out, int Nbits) { DisplayPowerOf2Approx(out, Nbits, 0.65); } -void Display035(std::ostream& out, int Nbits) +void Display_035(std::ostream& out, int Nbits) { DisplayPowerOf2Approx(out, Nbits, 0.35); } -void Display06535150354832(std::ostream& out, int Nbits) +void Display_065_3515_035_4832(std::ostream& out, int Nbits) { DisplaySumOfMultiply(out, Nbits, 0.65, 3515, 0.35, 4832); } @@ -153,9 +153,9 @@ int main(int argc, char** argv) // Open the stream to the file. std::ofstream output_file(argv[1]); - Loop(output_file, 2, 8, 2, Display065); - Loop(output_file, 2, 8, 2, Display035); - Loop(std::cout, 1, 8, 1, Display06535150354832); + Loop(output_file, 2, 8, 2, Display_065); + Loop(output_file, 2, 8, 2, Display_035); + Loop(std::cout, 1, 8, 1, Display_065_3515_035_4832); return EXIT_SUCCESS; } diff --git a/HandsOn/2-ObjectProgramming/Solution/exercice22.cpp b/HandsOn/2-ObjectProgramming/Solution/exercice22.cpp index a4b8031a2b0cc77726e18733286ffb0fc9fe8986..15432ad3d79c13692f9d64190a9d1479edf22a84 100644 --- a/HandsOn/2-ObjectProgramming/Solution/exercice22.cpp +++ b/HandsOn/2-ObjectProgramming/Solution/exercice22.cpp @@ -194,7 +194,7 @@ public: TestDisplayPowerOfTwoApprox(int resolution); //! To make the class a concrete one. - virtual ~TestDisplayPowerOfTwoApprox() ; + virtual ~TestDisplayPowerOfTwoApprox() override; protected: diff --git a/HandsOn/6-InRealEnvironment/Solution/Exercice43/Tools.hxx b/HandsOn/6-InRealEnvironment/Solution/Exercice43/Tools.hxx index bf0f258f86282024a7f16f53fba033f58a09633f..7a4b4b39b66d5eedb0cc43eb614d3e9327adf25c 100644 --- a/HandsOn/6-InRealEnvironment/Solution/Exercice43/Tools.hxx +++ b/HandsOn/6-InRealEnvironment/Solution/Exercice43/Tools.hxx @@ -1,5 +1,10 @@ +// We use here the new "auto-to-stick" way to define functions here. +// Without it, we would have to use the much more verbosy +// template<class IntT> +// inline typename PrintIntHelper<IntT>::return_type PrintIntHelper<IntT>::Do(IntT value) template<class IntT> -inline typename PrintIntHelper<IntT>::return_type PrintIntHelper<IntT>::Do(IntT value) +inline auto PrintIntHelper<IntT>::Do(IntT value) +-> return_type { return static_cast<return_type>(value); };