diff --git a/1-ProceduralProgramming/3-Types.ipynb b/1-ProceduralProgramming/3-Types.ipynb index bc821287676e4907e1e02a292243fdcc410e25e8..b79db01b4fae015ae7e061700324a4ee99dce135 100644 --- a/1-ProceduralProgramming/3-Types.ipynb +++ b/1-ProceduralProgramming/3-Types.ipynb @@ -207,6 +207,25 @@ "}" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "These enum types are really handy to make code more expressive, especially in function calls:\n", + "\n", + "````\n", + "f(print::yes, perform_checks::no);\n", + "````\n", + "\n", + "is much more expressive (and less error-prone) than:\n", + "\n", + "````\n", + "f(true, false);\n", + "````\n", + "\n", + "for which you will probably need to go check the prototype to figure out what each argument stands for." + ] + }, { "cell_type": "markdown", "metadata": {}, diff --git a/7-Appendix/Crtp.ipynb b/7-Appendix/Crtp.ipynb index 42d885868e22d227e2fb7a45e4b85ced70cbc316..4eb2af0548a6c28163acd1d3ac52a680ae602b96 100644 --- a/7-Appendix/Crtp.ipynb +++ b/7-Appendix/Crtp.ipynb @@ -50,7 +50,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -61,7 +61,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -87,7 +87,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -100,7 +100,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -111,7 +111,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -123,7 +123,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -133,7 +133,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -143,20 +143,9 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Carrot 0\n", - "Cabbage 2\n", - "Carrot 1\n", - "Cabbage 3\n" - ] - } - ], + "outputs": [], "source": [ "{\n", " Carrot carrot[2];\n", @@ -183,7 +172,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -215,7 +204,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -227,7 +216,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -239,20 +228,9 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Carrot 6\n", - "Cabbage 8\n", - "Carrot 7\n", - "Cabbage 9\n" - ] - } - ], + "outputs": [], "source": [ "{\n", " Carrot2 carrot[2];\n", @@ -281,37 +259,9 @@ }, { "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "\u001b[1minput_line_22:6:35: \u001b[0m\u001b[0;1;31merror: \u001b[0m\u001b[1mcannot cast 'Carrot2' to its private base class 'UniqueId'\u001b[0m\n", - " std::vector<UniqueId*> list { carrot, cabbage };\n", - "\u001b[0;1;32m ^\n", - "\u001b[0m\u001b[1minput_line_18:1:18: \u001b[0m\u001b[0;1;30mnote: \u001b[0mdeclared private here\u001b[0m\n", - "struct Carrot2 : private UniqueId\n", - "\u001b[0;1;32m ^~~~~~~~~~~~~~~~\n", - "\u001b[0m\u001b[1minput_line_22:6:43: \u001b[0m\u001b[0;1;31merror: \u001b[0m\u001b[1mcannot cast 'Cabbage2' to its private base class 'UniqueId'\u001b[0m\n", - " std::vector<UniqueId*> list { carrot, cabbage };\n", - "\u001b[0;1;32m ^\n", - "\u001b[0m\u001b[1minput_line_19:1:19: \u001b[0m\u001b[0;1;30mnote: \u001b[0mdeclared private here\u001b[0m\n", - "struct Cabbage2 : private UniqueId\n", - "\u001b[0;1;32m ^~~~~~~~~~~~~~~~\n", - "\u001b[0m" - ] - }, - { - "ename": "Interpreter Error", - "evalue": "", - "output_type": "error", - "traceback": [ - "Interpreter Error: " - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "#include <vector>\n", "\n", @@ -334,7 +284,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -358,7 +308,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -369,7 +319,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -382,7 +332,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -404,7 +354,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -415,7 +365,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -428,20 +378,9 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Carrot 10\n", - "Cabbage 12\n", - "Carrot 11\n", - "Cabbage 13\n" - ] - } - ], + "outputs": [], "source": [ "{\n", " Carrot3 carrot[2];\n", @@ -473,7 +412,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -500,7 +439,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -514,7 +453,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -526,7 +465,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -546,7 +485,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -556,7 +495,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -566,20 +505,9 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Carrot 0\n", - "Cabbage 0\n", - "Carrot 1\n", - "Cabbage 1\n" - ] - } - ], + "outputs": [], "source": [ "{\n", " Carrot4 carrot[2];\n", @@ -620,7 +548,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -635,7 +563,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -650,7 +578,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -664,7 +592,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -676,17 +604,9 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The name of the class is Tomato\n" - ] - } - ], + "outputs": [], "source": [ "{\n", " Tomato tomato;\n",