diff --git a/2-ObjectProgramming/3-constructors-destructor.ipynb b/2-ObjectProgramming/3-constructors-destructor.ipynb index 5cb7ac333e39f66d175b9ae54fcd9ee63af90640..59c681f68f69295065b4f766dd94c025524c164b 100644 --- a/2-ObjectProgramming/3-constructors-destructor.ipynb +++ b/2-ObjectProgramming/3-constructors-destructor.ipynb @@ -75,7 +75,7 @@ "outputs": [], "source": [ "Vector::Vector()\n", - ": x_(0.), // \n", + ": x_0.),\n", "y_(0.),\n", "z_(0.)\n", "{ }" @@ -210,7 +210,7 @@ " \n", " Vector2();\n", " \n", - " Vector2(double xyz);\n", + " Vector2(double x);\n", " \n", " Vector2(double x, double y, double z);\n", " \n", @@ -459,7 +459,7 @@ "source": [ "struct SafeClass\n", "{\n", - " int a_ = 5; // The default value is provided here in the class declaration. \n", + " int a_ { 5 }; // The default value is provided here in the class declaration. \n", " \n", " SafeClass() = default;\n", " \n", @@ -624,7 +624,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -645,7 +645,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -658,7 +658,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -673,20 +673,9 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Memory for array 3 is properly freed here.\n", - "Memory for array 4 is properly freed here.\n", - "Memory for array 2 is properly freed here.\n", - "Memory for array 1 is properly freed here.\n" - ] - } - ], + "outputs": [], "source": [ "{\n", " Array array1(1, 5ul);\n", diff --git a/2-ObjectProgramming/4-encapsulation.ipynb b/2-ObjectProgramming/4-encapsulation.ipynb index 73a7e9f76919d44db420a17c56550ca97a7e641b..b21da9167b78af773202707cfb762265b7293ccf 100644 --- a/2-ObjectProgramming/4-encapsulation.ipynb +++ b/2-ObjectProgramming/4-encapsulation.ipynb @@ -81,7 +81,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -105,7 +105,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -117,7 +117,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -131,7 +131,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -143,17 +143,9 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The value is 5\n" - ] - } - ], + "outputs": [], "source": [ "{\n", " SecondClass object(5);\n", @@ -163,31 +155,9 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "\u001b[1minput_line_13:4:12: \u001b[0m\u001b[0;1;31merror: \u001b[0m\u001b[1m'SetValue' is a private member of 'SecondClass'\u001b[0m\n", - " object.SetValue(7); // COMPILATION ERROR: trying to call publicly a private method\n", - "\u001b[0;1;32m ^\n", - "\u001b[0m\u001b[1minput_line_7:11:14: \u001b[0m\u001b[0;1;30mnote: \u001b[0mdeclared private here\u001b[0m\n", - " void SetValue(int a);\n", - "\u001b[0;1;32m ^\n", - "\u001b[0m" - ] - }, - { - "ename": "Interpreter Error", - "evalue": "", - "output_type": "error", - "traceback": [ - "Interpreter Error: " - ] - } - ], + "outputs": [], "source": [ "{\n", " SecondClass object(5);\n", @@ -222,13 +192,13 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ "struct Rectangle\n", "{\n", - " Rectangle(double length, double widgth);\n", + " Rectangle(double length, double width);\n", "\n", " double length_;\n", " double width_;\n", @@ -240,7 +210,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -253,31 +223,9 @@ }, { "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "\u001b[1minput_line_19:1:17: \u001b[0m\u001b[0;1;31merror: \u001b[0m\u001b[1mredefinition of 'Print'\u001b[0m\n", - "void Rectangle::Print() const\n", - "\u001b[0;1;32m ^\n", - "\u001b[0m\u001b[1minput_line_17:1:17: \u001b[0m\u001b[0;1;30mnote: \u001b[0mprevious definition is here\u001b[0m\n", - "void Rectangle::Print() const\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 <iostream>\n", "\n", @@ -289,18 +237,9 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "My rectangle is 5 x 4 so its area is 20\n", - "My rectangle is 23 x 4 so its area is 20\n" - ] - } - ], + "outputs": [], "source": [ "{\n", " Rectangle rect(5., 4.); \n", @@ -319,7 +258,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -340,7 +279,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -353,7 +292,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -367,31 +306,9 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "\u001b[1minput_line_25:5:10: \u001b[0m\u001b[0;1;31merror: \u001b[0m\u001b[1m'length_' is a private member of 'MoreSecureRectangle'\u001b[0m\n", - " rect.length_ = 0.; // can't do that! \n", - "\u001b[0;1;32m ^\n", - "\u001b[0m\u001b[1minput_line_21:9:16: \u001b[0m\u001b[0;1;30mnote: \u001b[0mdeclared private here\u001b[0m\n", - " double length_;\n", - "\u001b[0;1;32m ^\n", - "\u001b[0m" - ] - }, - { - "ename": "Interpreter Error", - "evalue": "", - "output_type": "error", - "traceback": [ - "Interpreter Error: " - ] - } - ], + "outputs": [], "source": [ "{\n", " MoreSecureRectangle rect(5., 4.); \n", @@ -409,7 +326,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -433,7 +350,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -446,7 +363,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -460,7 +377,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -473,7 +390,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -486,18 +403,9 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "My rectangle is 5 x 4 so its area is 20\n", - "My rectangle is 23 x 4 so its area is 92\n" - ] - } - ], + "outputs": [], "source": [ "{\n", " Rectangle3 rect(5., 4.); \n", @@ -530,7 +438,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -550,14 +458,14 @@ "\n", " private:\n", " \n", - " double length_ = -1.20; // a stupid value which at least is deterministically known...\n", - " double width_ = -1.20;\n", + " double length_ = -1.e20; // a stupid value which at least is deterministically known...\n", + " double width_ = -1.e20;\n", "};" ] }, { "cell_type": "code", - "execution_count": 23, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -569,7 +477,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -581,7 +489,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -593,7 +501,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -605,7 +513,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -617,7 +525,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -629,18 +537,9 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Area = 26\n", - "Area = 20\n" - ] - } - ], + "outputs": [], "source": [ "#include <iostream>\n", "\n", @@ -665,7 +564,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -700,7 +599,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -712,7 +611,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -726,7 +625,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -738,7 +637,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -751,7 +650,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -764,7 +663,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -778,19 +677,9 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Area is 12\n", - "Area is 32\n", - "Area is 16\n" - ] - } - ], + "outputs": [], "source": [ "{\n", " Rectangle5 rect(3., 4.);\n", @@ -826,7 +715,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -852,7 +741,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -865,7 +754,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -879,7 +768,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -899,7 +788,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -910,7 +799,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ diff --git a/2-ObjectProgramming/6-inheritance.ipynb b/2-ObjectProgramming/6-inheritance.ipynb index 37a03e94b4da4440af689dd528e784da4db51855..89a7e751b829d53d5e0b8c2b0d9cf435e8dea22b 100644 --- a/2-ObjectProgramming/6-inheritance.ipynb +++ b/2-ObjectProgramming/6-inheritance.ipynb @@ -25,14 +25,14 @@ "\n", "Sometimes, you might want to define two types that are related: one might be an extension of the other, or they may share some similarities we would like to put in common.\n", "\n", - "Let's suppose for instance you are asked to register all vehicles owned by your company. You could define independent classes `Bicyle`, `Scooter` and `Car`, but as a result storing them in a same `std::vector` would be impossible. \n", + "Let's suppose for instance you are asked to register all vehicles owned by your company. You could define independent classes `Bicycle`, `Scooter` and `Car`, but as a result storing them in a same `std::vector` would be impossible. \n", "\n", "The idea of inheritance is to provide a **base class** from which our classes are derived:" ] }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -50,7 +50,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -61,7 +61,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -76,7 +76,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -91,7 +91,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -102,7 +102,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -131,7 +131,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -145,7 +145,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -159,7 +159,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -173,7 +173,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -198,7 +198,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -228,7 +228,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -240,7 +240,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -252,7 +252,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -264,7 +264,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -276,7 +276,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -288,7 +288,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -302,7 +302,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -317,7 +317,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -335,7 +335,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -348,22 +348,9 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " ==== RECTANGLE ==== \n", - "My rectangle gets a length of 5 and a width of 3\n", - "My rectangle gets a length of 2.5 and a width of 6\n", - " ==== SQUARE ==== \n", - "My rectangle gets a length of 4 and a width of 4\n", - "My rectangle gets a length of 2 and a width of 8\n" - ] - } - ], + "outputs": [], "source": [ "{\n", " std::cout << \" ==== RECTANGLE ==== \" << std::endl;\n", @@ -402,7 +389,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -417,7 +404,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -428,40 +415,9 @@ }, { "cell_type": "code", - "execution_count": 24, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "\u001b[1minput_line_32:4:12: \u001b[0m\u001b[0;1;31merror: \u001b[0m\u001b[1m'SetWidth' is a private member of 'Rectangle'\u001b[0m\n", - " square.SetWidth(5.); // COMPILATION ERROR!\n", - "\u001b[0;1;32m ^\n", - "\u001b[0m\u001b[1minput_line_30:1:17: \u001b[0m\u001b[0;1;30mnote: \u001b[0mconstrained by private inheritance here\u001b[0m\n", - "class Square2 : private Rectangle\n", - "\u001b[0;1;32m ^~~~~~~~~~~~~~~~~\n", - "\u001b[0m\u001b[1minput_line_22:1:17: \u001b[0m\u001b[0;1;30mnote: \u001b[0mmember is declared here\u001b[0m\n", - "void Rectangle::SetWidth(double x)\n", - "\u001b[0;1;32m ^\n", - "\u001b[0m\u001b[1minput_line_32:4:5: \u001b[0m\u001b[0;1;31merror: \u001b[0m\u001b[1mcannot cast 'Square2' to its private base class 'Rectangle'\u001b[0m\n", - " square.SetWidth(5.); // COMPILATION ERROR!\n", - "\u001b[0;1;32m ^\n", - "\u001b[0m\u001b[1minput_line_30:1:17: \u001b[0m\u001b[0;1;30mnote: \u001b[0mdeclared private here\u001b[0m\n", - "class Square2 : private Rectangle\n", - "\u001b[0;1;32m ^~~~~~~~~~~~~~~~~\n", - "\u001b[0m" - ] - }, - { - "ename": "Interpreter Error", - "evalue": "", - "output_type": "error", - "traceback": [ - "Interpreter Error: " - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "{\n", " Square2 square(4.);\n", @@ -478,31 +434,9 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "\u001b[1minput_line_33:4:21: \u001b[0m\u001b[0;1;31merror: \u001b[0m\u001b[1mcannot cast 'Square2' to its private base class 'Rectangle'\u001b[0m\n", - " ModifyRectangle(square);\n", - "\u001b[0;1;32m ^\n", - "\u001b[0m\u001b[1minput_line_30:1:17: \u001b[0m\u001b[0;1;30mnote: \u001b[0mdeclared private here\u001b[0m\n", - "class Square2 : private Rectangle\n", - "\u001b[0;1;32m ^~~~~~~~~~~~~~~~~\n", - "\u001b[0m" - ] - }, - { - "ename": "Interpreter Error", - "evalue": "", - "output_type": "error", - "traceback": [ - "Interpreter Error: " - ] - } - ], + "outputs": [], "source": [ "{\n", " Square2 square(4.);\n", @@ -521,7 +455,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -539,7 +473,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -550,7 +484,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -563,18 +497,9 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "My rectangle gets a length of 4 and a width of 4\n", - "My rectangle gets a length of 3 and a width of 3\n" - ] - } - ], + "outputs": [], "source": [ "{\n", " Square3 square(4.);\n", @@ -597,7 +522,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -625,7 +550,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -637,7 +562,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -649,7 +574,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -661,7 +586,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -675,7 +600,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -687,18 +612,9 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "My rectangle gets a length of 4 and a width of 4\n", - "My rectangle gets a length of 3 and a width of 3\n" - ] - } - ], + "outputs": [], "source": [ "{\n", " Square4 square(4.);\n", @@ -743,7 +659,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -762,7 +678,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -776,35 +692,9 @@ }, { "cell_type": "code", - "execution_count": 39, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "\u001b[1minput_line_47:3:5: \u001b[0m\u001b[0;1;31merror: \u001b[0m\u001b[1m'DoNothing' is a private member of 'BaseClass'\u001b[0m\n", - " DoNothing()\n", - "\u001b[0;1;32m ^\n", - "\u001b[0m\u001b[1minput_line_45:9:14: \u001b[0m\u001b[0;1;30mnote: \u001b[0mdeclared private here\u001b[0m\n", - " void DoNothing() { }\n", - "\u001b[0;1;32m ^\n", - "\u001b[0m\u001b[1minput_line_47:3:16: \u001b[0m\u001b[0;1;31merror: \u001b[0m\u001b[1mexpected ';' after expression\u001b[0m\n", - " DoNothing()\n", - "\u001b[0;1;32m ^\n", - "\u001b[0m\u001b[0;32m ;\n", - "\u001b[0m" - ] - }, - { - "ename": "Interpreter Error", - "evalue": "", - "output_type": "error", - "traceback": [ - "Interpreter Error: " - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "DerivedClass::DerivedClass()\n", "{\n", @@ -821,7 +711,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -840,7 +730,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -854,7 +744,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -895,7 +785,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -909,7 +799,7 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -925,7 +815,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -937,7 +827,7 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -953,7 +843,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -965,28 +855,9 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "\u001b[1minput_line_56:7:13: \u001b[0m\u001b[0;1;31merror: \u001b[0m\u001b[1mno member named 'Nwheels' in 'Vehicle2'\u001b[0m\n", - " list[0].Nwheels(); // COMPILATION ERROR\n", - "\u001b[0;1;32m ~~~~~~~ ^\n", - "\u001b[0m" - ] - }, - { - "ename": "Interpreter Error", - "evalue": "", - "output_type": "error", - "traceback": [ - "Interpreter Error: " - ] - } - ], + "outputs": [], "source": [ "{\n", " Bicycle2 b;\n", @@ -1008,7 +879,7 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1044,7 +915,7 @@ }, { "cell_type": "code", - "execution_count": 50, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1056,7 +927,7 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1068,7 +939,7 @@ }, { "cell_type": "code", - "execution_count": 52, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1080,18 +951,9 @@ }, { "cell_type": "code", - "execution_count": 53, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Nwheels = 0\n", - "Nwheels = 0\n" - ] - } - ], + "outputs": [], "source": [ "#include <iostream>\n", "{\n", @@ -1131,7 +993,7 @@ }, { "cell_type": "code", - "execution_count": 54, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1166,7 +1028,7 @@ }, { "cell_type": "code", - "execution_count": 55, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1178,7 +1040,7 @@ }, { "cell_type": "code", - "execution_count": 56, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1190,7 +1052,7 @@ }, { "cell_type": "code", - "execution_count": 57, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1216,7 +1078,7 @@ }, { "cell_type": "code", - "execution_count": 58, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1248,28 +1110,9 @@ }, { "cell_type": "code", - "execution_count": 59, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "\u001b[1minput_line_68:6:21: \u001b[0m\u001b[0;1;31merror: \u001b[0m\u001b[1m'Nwhels' marked 'override' but does not override any member functions\u001b[0m\n", - " virtual int Nwhels() const override; // Please notice the missing 'e', that now triggers a compilation error!\n", - "\u001b[0;1;32m ^\n", - "\u001b[0m" - ] - }, - { - "ename": "Interpreter Error", - "evalue": "", - "output_type": "error", - "traceback": [ - "Interpreter Error: " - ] - } - ], + "outputs": [], "source": [ "class Car4_typo_override : public Vehicle4_typo\n", "{\n", @@ -1290,18 +1133,9 @@ }, { "cell_type": "code", - "execution_count": 60, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Nwheels = 0\n", - "Nwheels = 0\n" - ] - } - ], + "outputs": [], "source": [ "#include <iostream>\n", "{\n", @@ -1326,18 +1160,9 @@ }, { "cell_type": "code", - "execution_count": 61, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Nwheels = 2\n", - "Nwheels = 4\n" - ] - } - ], + "outputs": [], "source": [ "#include <iostream>\n", "{\n", @@ -1365,19 +1190,9 @@ }, { "cell_type": "code", - "execution_count": 62, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Nwheels = 2\n", - "Nwheels = 4\n", - "Nwheels = 0\n" - ] - } - ], + "outputs": [], "source": [ "#include <iostream>\n", "{\n", @@ -1409,7 +1224,7 @@ }, { "cell_type": "code", - "execution_count": 63, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1444,7 +1259,7 @@ }, { "cell_type": "code", - "execution_count": 64, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1456,7 +1271,7 @@ }, { "cell_type": "code", - "execution_count": 65, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1468,31 +1283,9 @@ }, { "cell_type": "code", - "execution_count": 66, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "\u001b[1minput_line_78:3:14: \u001b[0m\u001b[0;1;31merror: \u001b[0m\u001b[1mvariable type 'Vehicle5' is an abstract class\u001b[0m\n", - " Vehicle5 v; // Compilation error: you can't instantiate an abstract class!\n", - "\u001b[0;1;32m ^\n", - "\u001b[0m\u001b[1minput_line_75:6:21: \u001b[0m\u001b[0;1;30mnote: \u001b[0munimplemented pure virtual method 'Nwheels' in 'Vehicle5'\u001b[0m\n", - " virtual int Nwheels() const = 0; // The only change from Vehicle4!\n", - "\u001b[0;1;32m ^\n", - "\u001b[0m" - ] - }, - { - "ename": "Interpreter Error", - "evalue": "", - "output_type": "error", - "traceback": [ - "Interpreter Error: " - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "{ \n", " Vehicle5 v; // Compilation error: you can't instantiate an abstract class!\n", @@ -1508,18 +1301,9 @@ }, { "cell_type": "code", - "execution_count": 67, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Nwheels = 2\n", - "Nwheels = 4\n" - ] - } - ], + "outputs": [], "source": [ "#include <iostream>\n", "{\n", @@ -1553,7 +1337,7 @@ }, { "cell_type": "code", - "execution_count": 68, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1576,7 +1360,7 @@ }, { "cell_type": "code", - "execution_count": 69, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1588,7 +1372,7 @@ }, { "cell_type": "code", - "execution_count": 70, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1600,28 +1384,9 @@ }, { "cell_type": "code", - "execution_count": 71, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "\u001b[1minput_line_85:4:38: \u001b[0m\u001b[0;1;31merror: \u001b[0m\u001b[1mno member named 'GetOilType' in 'Vehicle5'\u001b[0m\n", - " std::cout << \"Oil type = \" << c->GetOilType() << std::endl; // compilation error: been there before...\n", - "\u001b[0;1;32m ~ ^\n", - "\u001b[0m" - ] - }, - { - "ename": "Interpreter Error", - "evalue": "", - "output_type": "error", - "traceback": [ - "Interpreter Error: " - ] - } - ], + "outputs": [], "source": [ "#include <iostream>\n", "\n", @@ -1642,22 +1407,9 @@ }, { "cell_type": "code", - "execution_count": 72, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "IncrementalExecutor::executeFunction: symbol '_ZTV11Car5WithOil' unresolved while linking [cling interface function]!\n", - "You are probably missing the definition of vtable for Car5WithOil\n", - "Maybe you need to load the corresponding shared library?\n", - "IncrementalExecutor::executeFunction: symbol '_ZTI11Car5WithOil' unresolved while linking [cling interface function]!\n", - "You are probably missing the definition of typeinfo for Car5WithOil\n", - "Maybe you need to load the corresponding shared library?\n" - ] - } - ], + "outputs": [], "source": [ "// Xeus-cling issue!\n", "\n", @@ -1695,7 +1447,7 @@ }, { "cell_type": "code", - "execution_count": 73, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1705,31 +1457,9 @@ }, { "cell_type": "code", - "execution_count": 74, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "\u001b[1minput_line_90:1:27: \u001b[0m\u001b[0;1;31merror: \u001b[0m\u001b[1mbase 'UnderivableClass' is marked 'final'\u001b[0m\n", - "class ITryAnyway : public UnderivableClass\n", - "\u001b[0;1;32m ^\n", - "\u001b[0m\u001b[1minput_line_89:2:8: \u001b[0m\u001b[0;1;30mnote: \u001b[0m'UnderivableClass' declared here\u001b[0m\n", - " class UnderivableClass final\n", - "\u001b[0;1;32m ^ ~~~~~\n", - "\u001b[0m" - ] - }, - { - "ename": "Interpreter Error", - "evalue": "", - "output_type": "error", - "traceback": [ - "Interpreter Error: " - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "class ITryAnyway : public UnderivableClass\n", "{ };" @@ -1744,7 +1474,7 @@ }, { "cell_type": "code", - "execution_count": 75, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1757,7 +1487,7 @@ }, { "cell_type": "code", - "execution_count": 76, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1770,7 +1500,7 @@ }, { "cell_type": "code", - "execution_count": 77, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1782,31 +1512,9 @@ }, { "cell_type": "code", - "execution_count": 78, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "\u001b[1minput_line_94:3:18: \u001b[0m\u001b[0;1;31merror: \u001b[0m\u001b[1mdeclaration of 'Method1' overrides a 'final' function\u001b[0m\n", - " virtual void Method1() override; // compilation error!\n", - "\u001b[0;1;32m ^\n", - "\u001b[0m\u001b[1minput_line_92:3:18: \u001b[0m\u001b[0;1;30mnote: \u001b[0moverridden virtual function is here\u001b[0m\n", - " virtual void Method1() override final;\n", - "\u001b[0;1;32m ^\n", - "\u001b[0m" - ] - }, - { - "ename": "Interpreter Error", - "evalue": "", - "output_type": "error", - "traceback": [ - "Interpreter Error: " - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "struct DerivedClassSecondLevelIgnoreFinal : public DerivedClassFirstLevel\n", "{\n", @@ -1825,7 +1533,7 @@ }, { "cell_type": "code", - "execution_count": 79, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1839,7 +1547,7 @@ }, { "cell_type": "code", - "execution_count": 80, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1854,7 +1562,7 @@ }, { "cell_type": "code", - "execution_count": 81, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1866,7 +1574,7 @@ }, { "cell_type": "code", - "execution_count": 82, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1880,7 +1588,7 @@ }, { "cell_type": "code", - "execution_count": 83, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1892,7 +1600,7 @@ }, { "cell_type": "code", - "execution_count": 84, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1904,26 +1612,9 @@ }, { "cell_type": "code", - "execution_count": 85, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Here all should be well: \n", - "BaseClass3 constructor\n", - "DerivedClass3 constructor\n", - "DerivedClass3 destructor\n", - "BaseClass3 destructor\n", - "\n", - "But there not so much, see the missing destructor call! \n", - "BaseClass3 constructor\n", - "DerivedClass3 constructor\n", - "BaseClass3 destructor\n" - ] - } - ], + "outputs": [], "source": [ "{\n", " std::cout << \"Here all should be well: \" << std::endl;\n", @@ -1973,7 +1664,7 @@ }, { "cell_type": "code", - "execution_count": 86, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1989,7 +1680,7 @@ }, { "cell_type": "code", - "execution_count": 87, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -2003,7 +1694,7 @@ }, { "cell_type": "code", - "execution_count": 88, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -2017,7 +1708,7 @@ }, { "cell_type": "code", - "execution_count": 89, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -2029,7 +1720,7 @@ }, { "cell_type": "code", - "execution_count": 90, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -2041,18 +1732,9 @@ }, { "cell_type": "code", - "execution_count": 91, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello! I'm BaseClass4\n", - "Hello! I'm BaseClass4\n" - ] - } - ], + "outputs": [], "source": [ "{\n", " DerivedClass4 object; // nope by stack allocation\n", @@ -2072,7 +1754,7 @@ }, { "cell_type": "code", - "execution_count": 92, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -2090,7 +1772,7 @@ }, { "cell_type": "code", - "execution_count": 93, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -2104,7 +1786,7 @@ }, { "cell_type": "code", - "execution_count": 94, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -2118,7 +1800,7 @@ }, { "cell_type": "code", - "execution_count": 95, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -2130,7 +1812,7 @@ }, { "cell_type": "code", - "execution_count": 96, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -2142,18 +1824,9 @@ }, { "cell_type": "code", - "execution_count": 97, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello! I'm DerivedClass5\n", - "Hello! I'm DerivedClass5\n" - ] - } - ], + "outputs": [], "source": [ "{\n", " DerivedClass5 object; // nope by stack allocation\n",