diff --git a/1-ProceduralProgramming/4-Functions.ipynb b/1-ProceduralProgramming/4-Functions.ipynb index 69a9c3766d944fa8aa28a681161b19bf2c5a80d4..3cd54af24d944efb2484a12b42458049b0ca2dc2 100644 --- a/1-ProceduralProgramming/4-Functions.ipynb +++ b/1-ProceduralProgramming/4-Functions.ipynb @@ -57,7 +57,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Due to the use of notebooks we will not need to seperate clearly function declaration from its definition, but we will revisit this [much later](../6-InRealEnvironment/2-FileStructure.ipynb) when we will see how a real project is written with different files involved." + "Due to the use of notebooks we will not need to separate clearly function declaration from its definition, but we will revisit this [much later](../6-InRealEnvironment/2-FileStructure.ipynb) when we will see how a real project is written with different files involved." ] }, { diff --git a/2-ObjectProgramming/3b-hands-on.ipynb b/2-ObjectProgramming/3b-hands-on.ipynb index b42018994c40d820058e03628d929286c5003fb6..54f4d10ff5081fb37fb77a327dd440824ca7bf43 100644 --- a/2-ObjectProgramming/3b-hands-on.ipynb +++ b/2-ObjectProgramming/3b-hands-on.ipynb @@ -13,7 +13,7 @@ "source": [ "### **EXERCISE 15: change interface of `PowerOfTwoApprox` struct**\n", "\n", - "* Transform `Compute()` into a constructor. As a constructor cannot return a value (it returns an object!), introduce a method `AsDouble()` which returns the approximation (that by definition may be computed from data attributes `numerator_` and `exponent_`).\n", + "* Transform `Compute()` into a constructor. As a constructor cannot return a value, introduce a method `AsDouble()` which returns the approximation (that by definition may be computed from data attributes `numerator_` and `exponent_`).\n", "* Assign a default value of `0` to data attributes (if not already done previously!)\n", "\n", "Expected output is the same as previously.\n", diff --git a/4-Templates/1-Intro.ipynb b/4-Templates/1-Intro.ipynb index 7cb04739390693ee0c936f84c63049956be16e57..8218cad7debbbc53b3bef99c199f217da0553e88 100644 --- a/4-Templates/1-Intro.ipynb +++ b/4-Templates/1-Intro.ipynb @@ -655,7 +655,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Since C++17, there are exactly zero differences between both keywords; some authors suggest conventions (e.g. use `typename` for POD types and `class` for the more complicated types) but they are just that: conventions!\n", + "Since C++ 17, there are exactly zero differences between both keywords (before C++ 17, they were almost everywhere equivalent except in a very specific case - called template template parameter that we'll see shortly - in which typename did not work. You can check [this link](https://stackoverflow.com/questions/2023977/what-is-the-difference-between-typename-and-class-template-parameters) if you want to know more); some authors suggest conventions (e.g. use `typename` for POD types and `class` for the more complicated types) but they are just that: conventions!\n", "\n", "* The definition of the templates must be provided in header files, not in compiled files. The reason is that the compiler can't know all the types for which the template might be used: you may use `std::min` for your own defined types (provided they define a `<` operator...) and obviously STL writers can't foresee which type you will come up with!\n", "* The compiler will generate the code for each type given to the template; for instance if `Convert<double>`, `Convert<unsigned int>` and `Convert<short>` are used in your code, the content of this template function will be instantiated thrice! This can lead to **code bloat**: lots of assembler code is generated, and compilation time may increase significatively. \n", diff --git a/5-UsefulConceptsAndSTL/5-MoveSemantics.ipynb b/5-UsefulConceptsAndSTL/5-MoveSemantics.ipynb index 22d69f7592e169494e8fa79dee59a571543dd64e..f09db6e3ffc314b3a1b0bde1c8c1d63f8e8781b0 100644 --- a/5-UsefulConceptsAndSTL/5-MoveSemantics.ipynb +++ b/5-UsefulConceptsAndSTL/5-MoveSemantics.ipynb @@ -901,7 +901,7 @@ "source": [ "## Forwarding reference (or universal reference)\n", "\n", - "Just a quick warning (you should really read [Effective modern C++](../bibliography.ipynb#Effective-Modern-C++) for an extensive discussion on the topic; blog [FluentCpp](https://www.fluentcpp.com/2018/02/06/understanding-lvalues-rvalues-and-their-references) provides some intel about it... and tells you as well to really Scott Meyer's book to learn more!): seeing `&&` doesn't automatically mean it is a r-value reference.\n", + "Just a quick warning (you should really read [Effective modern C++](../bibliography.ipynb#Effective-Modern-C++) for an extensive discussion on the topic; blog [FluentCpp](https://www.fluentcpp.com/2018/02/06/understanding-lvalues-rvalues-and-their-references) provides some intel about it... and tells you as well to read Scott Meyer's book to learn more!): seeing `&&` doesn't automatically mean it is a r-value reference.\n", "\n", "There is a very specific case when:\n", "- The argument is template \n", diff --git a/HandsOn/2-ObjectProgramming/Solution/exercise13.cpp b/HandsOn/2-ObjectProgramming/Solution/exercise13.cpp index f2e113fb4e44620033af922ce02e1c743aa23b90..53bb7ed0608aa58a8079c615a32cbbab64a55218 100644 --- a/HandsOn/2-ObjectProgramming/Solution/exercise13.cpp +++ b/HandsOn/2-ObjectProgramming/Solution/exercise13.cpp @@ -11,8 +11,8 @@ struct PowerOfTwoApprox { - int numerator_ {}; - int exponent_ {}; + int numerator {}; + int exponent {}; }; @@ -102,8 +102,8 @@ void DisplayPowerOf2Approx(int Nbits, double value) const double error = std::fabs(value - double_quotient) / value; - std::cout << "[With " << Nbits << " bits]: " << value << " ~ " << double_quotient << " (" << approximation.numerator_ << - " / 2^" << approximation.exponent_ << ") [error = " << RoundAsInt(100. * error) << "/100]" << std::endl; + std::cout << "[With " << Nbits << " bits]: " << value << " ~ " << double_quotient << " (" << approximation.numerator << + " / 2^" << approximation.exponent << ") [error = " << RoundAsInt(100. * error) << "/100]" << std::endl; } @@ -117,8 +117,8 @@ double ComputePowerOf2Approx(int Nbits, double value, PowerOfTwoApprox& approxim { int max_numerator = MaxInt(Nbits); - auto& numerator = approximation.numerator_; // alias! - auto& exponent = approximation.exponent_; // alias! + auto& numerator = approximation.numerator; // alias! + auto& exponent = approximation.exponent; // alias! int denominator {}; @@ -144,7 +144,7 @@ int Multiply(int Nbits, double value, int coefficient) ComputePowerOf2Approx(Nbits, value, approximation); - return TimesPowerOf2(approximation.numerator_ * coefficient, -approximation.exponent_); + return TimesPowerOf2(approximation.numerator * coefficient, -approximation.exponent); }