Commit 9221c943 authored by STEFF Laurent's avatar STEFF Laurent
Browse files

fixed typos in op

parent 41a90447
...@@ -564,7 +564,7 @@ ...@@ -564,7 +564,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"## Good practice: define the attribute in the same order they are defined\n", "## Good practice: define the attribute in the same order they are declared\n",
"\n", "\n",
"Data attributes should be defined in the exact same order they are declared within the class. " "Data attributes should be defined in the exact same order they are declared within the class. "
] ]
...@@ -604,7 +604,7 @@ ...@@ -604,7 +604,7 @@
"\n", "\n",
"Most of the time it doesn't matter much, but if there are dependencies between attributes it might create havoc so take the habit to respect the ordering.\n", "Most of the time it doesn't matter much, but if there are dependencies between attributes it might create havoc so take the habit to respect the ordering.\n",
"\n", "\n",
"Of course, you may not declare explicitly a data attribute for which you provide a default value at declaration:" "Of course, you may not define explicitly a data attribute for which you provide a default value at declaration:"
] ]
}, },
{ {
......
...@@ -821,7 +821,7 @@ ...@@ -821,7 +821,7 @@
"Vector v(2., 3., 5.);\n", "Vector v(2., 3., 5.);\n",
"\n", "\n",
"PrintVector printer(v);\n", "PrintVector printer(v);\n",
"print_object.Print();\n" "printer.Print();\n"
] ]
}, },
{ {
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
"source": [ "source": [
"## Static in C\n", "## Static in C\n",
"\n", "\n",
"As a reminder, we have seen in a [previous notebook](./1-ProceduralProgramming/7-StaticAndConstexpr.ipynb#Static-keyword) the `static` keyword inherited from C. \n", "As a reminder, we have seen in a [previous notebook](../1-ProceduralProgramming/7-StaticAndConstexpr.ipynb#Static-keyword) the `static` keyword inherited from C. \n",
"\n", "\n",
"What follows is the same keyword used in a very different context (even if the one we already know will pop up in an idiom presented here).\n" "What follows is the same keyword used in a very different context (even if the one we already know will pop up in an idiom presented here).\n"
] ]
......
...@@ -349,7 +349,7 @@ ...@@ -349,7 +349,7 @@
" \n", " \n",
" double width_ { -1.e20 } ; // Stupid value that would play havoc if not properly initialized\n", " double width_ { -1.e20 } ; // Stupid value that would play havoc if not properly initialized\n",
" // - std::optional (C++17) would probably a better choice.\n", " // - std::optional (C++17) would probably a better choice.\n",
" double length_ { -1.e20 } \n", " double length_ { -1.e20 } ; \n",
"};" "};"
] ]
}, },
...@@ -504,14 +504,14 @@ ...@@ -504,14 +504,14 @@
"\n", "\n",
"Don't get me wrong: public inheritance is very handy, as we shall see more below with the introduction of polymorphism. It's just that you need to assess properly first what your needs are, and decide which is the more appropriate answer - and sometimes the most obvious one is not the best.\n", "Don't get me wrong: public inheritance is very handy, as we shall see more below with the introduction of polymorphism. It's just that you need to assess properly first what your needs are, and decide which is the more appropriate answer - and sometimes the most obvious one is not the best.\n",
"\n", "\n",
"The public inheritance is an application of the [Liskov substitution principe](https://en.wikipedia.org/wiki/Liskov_substitution_principle).\n", "The public inheritance is an application of the [Liskov substitution principle](https://en.wikipedia.org/wiki/Liskov_substitution_principle).\n",
"\n", "\n",
"We will now \"fix\" our `Square` problem with two different idioms: private inheritance and composition.\n", "We will now \"fix\" our `Square` problem with two different idioms: private inheritance and composition.\n",
"\n", "\n",
"\n", "\n",
"### IS-IMPLEMENTED-IN-TERMS-OF relationship of private inheritance\n", "### IS-IMPLEMENTED-IN-TERMS-OF relationship of private inheritance\n",
"\n", "\n",
"What you might look at in fact is **private** inheritance, in which all the inherited attributes are considered private:" "What you might look for in fact is **private** inheritance, in which all the inherited attributes are considered private:"
] ]
}, },
{ {
...@@ -767,7 +767,7 @@ ...@@ -767,7 +767,7 @@
"So what are the pros and cons of private inheritance and composition?\n", "So what are the pros and cons of private inheritance and composition?\n",
" \n", " \n",
"- No granularity with private inheritance: you get all the interface available (privately) in the derived class. On the other hand, with composition you can choose which method you want to expose publicly in your new class (only `Print()` here).\n", "- No granularity with private inheritance: you get all the interface available (privately) in the derived class. On the other hand, with composition you can choose which method you want to expose publicly in your new class (only `Print()` here).\n",
"- But composition is more verbosy: if you want most of the interface, you need for each method to define a method which under the hood calls your data attribute (as did `Square4::Print()` above). So in you need most of the API of the base class private inheritance is less work.\n", "- But composition is more verbosy: if you want most of the interface, you need for each method to define a method which under the hood calls your data attribute (as did `Square4::Print()` above). So if you need most of the API of the base class private inheritance is less work.\n",
"\n", "\n",
"As indicated before, I tend to use more composition, but it's nice anyway to know both are available.\n" "As indicated before, I tend to use more composition, but it's nice anyway to know both are available.\n"
] ]
......
...@@ -196,7 +196,7 @@ ...@@ -196,7 +196,7 @@
"\n", "\n",
"void AlsoNotPolymorphicCar::Print() const\n", "void AlsoNotPolymorphicCar::Print() const\n",
"{\n", "{\n",
" std::cout << \"I'm a bike!\" << std::endl;\n", " std::cout << \"I'm a car!\" << std::endl;\n",
"}" "}"
] ]
}, },
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment