Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

Commit 477ee2c2 authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

Updating and cleaning-up introduction and procedural programming part. The...

Updating and cleaning-up introduction and procedural programming part. The section introducing pointers and references has been refactored a bit.
parent ac2187cd
......@@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# [Getting started in C++](/) - [Getting started with the tutorial](/notebooks/getting_started_with_tutorial.ipynb)"
"# [Getting started in C++](/) - [Getting started with the tutorial](./getting_started_with_tutorial.ipynb)"
]
},
{
......@@ -27,7 +27,7 @@
"\n",
"The reasons for these choices is to really access directly to handle C++ code without the hassle of explaining how to compile and run stuff, which is an especially cumbersome way to start with this (or any really...) language.\n",
"\n",
"This is not to say this tutorial will ignore entirely these topics (see the dedicated [chapter](/notebooks/6-InRealEnvironment/0-main.ipynb), just that we will first focus on C++ code. However keep in mind that this notebook's fancy interpreter is not a typical C++ environment.\n",
"This is not to say this tutorial will ignore entirely these topics (see the dedicated [chapter](./6-InRealEnvironment/0-main.ipynb)), just that we will first focus on C++ code. However keep in mind that this notebook's fancy interpreter is not a typical C++ environment.\n",
"\n",
"Jupyter Xeus-Cling is still under active development: you should really get a recent version and keep it up-to-date. Some examples in this lecture didn't work at first and were properly dealt with with a version one month later!\n",
"\n",
......@@ -124,11 +124,11 @@
"source": [
" # include <string>\n",
"{\n",
" int nombre ; nombre = 1\n",
" ; std::string nom;\n",
" nom=\n",
" int number ; number = 1\n",
" ; std::string name;\n",
" name=\n",
" \"truc\" ;\n",
" nombre = 2\n",
" number = 2\n",
" ;\n",
"}"
]
......@@ -141,7 +141,7 @@
"\n",
"You may have notices the braces `{` and `}` in the examples above. They are here a technicality to make cling interpreter work better in a Jupyter environment, but that is also useful in a real C++ code.\n",
"\n",
"What is between both braces constitute a **block**; variables that are initialized inside are destroyed once the closing brace is past (don't worry - we will come back to that [later](/notebooks/1-ProceduralProgramming/5-DynamicAllocation.ipynb#Stack)).\n",
"What is between both braces constitute a **block**; variables that are initialized inside are destroyed once the closing brace is past (don't worry - we will come back to that [later](./1-ProceduralProgramming/5-DynamicAllocation.ipynb#Stack)).\n",
"\n",
"This is an incredibly useful feature: you may ensure this way that a variable is not kept any longer than necessary. We will come back to this feature (called the **locality of reference** later); let's see why they are useful in a notebook environment.\n",
"\n",
......@@ -239,7 +239,7 @@
"\n",
"The operator `<<` is used to indicate what you direct toward the stream; here std::cout << \"Hello world!\" tells to redirect the string toward the standard output.\n",
"\n",
"We will see that a bit more in detail in [a later chapter](/notebooks/1-ProceduralProgramming/6-Streams.ipynb), but printing something is really helpful early on hence this brief introduction here.\n"
"We will see that a bit more in detail in [a later chapter](./1-ProceduralProgramming/6-Streams.ipynb), but printing something is really helpful early on hence this brief introduction here.\n"
]
},
{
......@@ -250,13 +250,13 @@
"\n",
"There are two ways to comment code in C++:\n",
"\n",
"- `//` which comments all that is after this symbol on the same line\n",
"- `//` which comments all that is after this symbol on the same line.\n",
"- `/*` ... `*/` which comments everything in the between the symbols.\n"
]
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
......@@ -274,7 +274,7 @@
" \n",
" /*\n",
" \n",
" // This type of comment might be in the other style\n",
" // This type of comment might be used inside the other style\n",
" \n",
" */\n",
"}"
......@@ -285,7 +285,7 @@
"metadata": {},
"source": [
"\n",
"© _CNRS 2016_ - _Inria 2018-2019_ \n",
"© _CNRS 2016_ - _Inria 2018-2020_ \n",
"_This notebook is an adaptation of a lecture prepared by David Chamont (CNRS) under the terms of the licence [Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)](http://creativecommons.org/licenses/by-nc-sa/4.0/)_ \n",
"_The present version has been written by Sébastien Gilles and Vincent Rouvreau (Inria)_"
]
......@@ -295,14 +295,14 @@
"kernelspec": {
"display_name": "C++17",
"language": "C++17",
"name": "xeus-cling-cpp17"
"name": "xcpp17"
},
"language_info": {
"codemirror_mode": "text/x-c++src",
"file_extension": ".cpp",
"mimetype": "text/x-c++src",
"name": "c++",
"version": "-std=c++17"
"version": "17"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
......@@ -337,5 +337,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
......@@ -4,22 +4,22 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# [Getting started in C++](/) - [Procedural programming](/notebooks/1-ProceduralProgramming/0-main.ipynb)"
"# [Getting started in C++](/) - [Procedural programming](./0-main.ipynb)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* [Variables, initialisation, affectation](/notebooks/1-ProceduralProgramming/1-Variables.ipynb)\n",
"* [Condition and loops](/notebooks/1-ProceduralProgramming/2-Conditions-and-loops.ipynb)\n",
" * [TP 1](/notebooks/1-ProceduralProgramming/2b-TP.ipynb)\n",
"* [Predefined types](/notebooks/1-ProceduralProgramming/3-Types.ipynb)\n",
"* [Functions](/notebooks/1-ProceduralProgramming/4-Functions.ipynb)\n",
" * [TP 2](/notebooks/1-ProceduralProgramming/4b-TP.ipynb)\n",
"* [Dynamic allocation](/notebooks/1-ProceduralProgramming/5-DynamicAllocation.ipynb)\n",
"* [Input/output](/notebooks/1-ProceduralProgramming/6-Streams.ipynb)\n",
" * [TP 3](/notebooks/1-ProceduralProgramming/6b-TP.ipynb)"
"* [Variables, initialisation, affectation](./1-Variables.ipynb)\n",
"* [Condition and loops](./2-Conditions-and-loops.ipynb)\n",
" * [TP 1](./2b-TP.ipynb)\n",
"* [Predefined types](./3-Types.ipynb)\n",
"* [Functions](./4-Functions.ipynb)\n",
" * [TP 2](./4b-TP.ipynb)\n",
"* [Dynamic allocation](./5-DynamicAllocation.ipynb)\n",
"* [Input/output](./6-Streams.ipynb)\n",
" * [TP 3](./6b-TP.ipynb)"
]
},
{
......@@ -27,7 +27,7 @@
"metadata": {},
"source": [
"\n",
"© _CNRS 2016_ - _Inria 2018-2019_ \n",
"© _CNRS 2016_ - _Inria 2018-2020_ \n",
"_This notebook is an adaptation of a lecture prepared by David Chamont (CNRS) under the terms of the licence [Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)](http://creativecommons.org/licenses/by-nc-sa/4.0/)_ \n",
"_The present version has been written by Sébastien Gilles and Vincent Rouvreau (Inria)_"
]
......@@ -37,14 +37,14 @@
"kernelspec": {
"display_name": "C++17",
"language": "C++17",
"name": "xeus-cling-cpp17"
"name": "xcpp17"
},
"language_info": {
"codemirror_mode": "text/x-c++src",
"file_extension": ".cpp",
"mimetype": "text/x-c++src",
"name": "c++",
"version": "-std=c++17"
"version": "17"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
......@@ -79,5 +79,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
This diff is collapsed.
......@@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# [Getting started in C++](/) - [Procedural programming](/notebooks/1-ProceduralProgramming/0-main.ipynb) - [Conditions and loops](/notebooks/1-ProceduralProgramming/2-Conditions-and-loops.ipynb)"
"# [Getting started in C++](/) - [Procedural programming](./0-main.ipynb) - [Conditions and loops](./2-Conditions-and-loops.ipynb)"
]
},
{
......@@ -282,7 +282,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"With if/else it doesn't work: both ways to do so that might step in mind are flawed:"
"With if/else this doesn't work: both ways to do so that might step in mind are flawed:"
]
},
{
......@@ -331,10 +331,10 @@
"\n",
"Very briefly: there is also a `switch` statement that can be used when:\n",
"\n",
"* The variable is an integer, an enum (see [next notebook](/notebooks/1-ProceduralProgramming/3-Types.ipynb#Enumerations)) or might be convertible into one of those.\n",
"* The variable is an integer, an enum (see [next notebook](./3-Types.ipynb#Enumerations)) or might be convertible into one of those.\n",
"* The relationship considered is an equality.\n",
"\n",
"I present it quickly in [appendix](/notebooks/7-Appendix/Switch.ipynb) but we do not have yet seen all the elements needed to explain its interest.\n"
"I present it quickly in [appendix](../7-Appendix/Switch.ipynb) but we do not have yet seen all the elements needed to explain its interest.\n"
]
},
{
......@@ -427,8 +427,6 @@
" if (a > 0 || ++b < 10)\n",
" std::cout << \"b is still \" << b << \": as the first operand was true ++b was never evaluated.\" << std::endl; \n",
"\n",
" b = 3;\n",
" \n",
" if (++b < 10 || a > 0)\n",
" std::cout << \"b is now \" << b << \": the first operand run is not the same...\" << std::endl;\n",
"}"
......@@ -599,7 +597,7 @@
"\n",
"{\n",
" int i = 0; // i might also be declared and initialized outside the block\n",
" for ( ; i < 5; )\n",
" for ( ; i < 5; ) // completely equivalent to `while(i < 5)`\n",
" {\n",
" ++i; // i might also be modified within the block\n",
" std::cout << i << std::endl; \n",
......@@ -764,34 +762,9 @@
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2 is even and prime (hello 2!).\n",
"3 is odd and prime.\n",
"4 is even.\n",
"5 is odd and prime.\n",
"6 is even.\n",
"7 is odd and prime.\n",
"8 is even.\n",
"9 is odd.\n",
"10 is even.\n",
"11 is odd and prime.\n",
"12 is even.\n",
"13 is odd and prime.\n",
"14 is even.\n",
"15 is odd.\n",
"16 is even.\n",
"17 is odd and prime.\n",
"18 is even.\n",
"19 is odd and prime.\n"
]
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#include <iostream>\n",
"\n",
......@@ -833,7 +806,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Of course, in a trivial example like this one we could have written it much more cleanly without any `continue`, but in more complex cases it is really handful to use it: not using it could lead to code much more complicated to understand, and you really should always strive for code that is the most palatable for a reader."
"Of course, in a trivial example like this one we could have written it much more cleanly without any `continue`, but in more complex cases it is really handful to use it: not using it could lead to code much more complicated to understand, and you really should always strive for code that is the most expressive for a reader."
]
},
{
......@@ -864,7 +837,7 @@
"metadata": {},
"source": [
"\n",
"© _CNRS 2016_ - _Inria 2018-2019_ \n",
"© _CNRS 2016_ - _Inria 2018-2020_ \n",
"_This notebook is an adaptation of a lecture prepared by David Chamont (CNRS) under the terms of the licence [Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)](http://creativecommons.org/licenses/by-nc-sa/4.0/)_ \n",
"_The present version has been written by Sébastien Gilles and Vincent Rouvreau (Inria)_"
]
......@@ -874,14 +847,14 @@
"kernelspec": {
"display_name": "C++17",
"language": "C++17",
"name": "xeus-cling-cpp17"
"name": "xcpp17"
},
"language_info": {
"codemirror_mode": "text/x-c++src",
"file_extension": ".cpp",
"mimetype": "text/x-c++src",
"name": "c++",
"version": "-std=c++17"
"version": "17"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
......@@ -916,5 +889,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
......@@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# [Getting started in C++](/) - [Procedural programming](/notebooks/1-ProceduralProgramming/0-main.ipynb) - [TP 1](/notebooks/1-ProceduralProgramming/4b-TP.ipynb)"
"# [Getting started in C++](/) - [Procedural programming](./0-main.ipynb) - [TP 1](./4b-TP.ipynb)"
]
},
{
......@@ -71,25 +71,32 @@
"metadata": {},
"source": [
"\n",
"© _CNRS 2016_ - _Inria 2018-2019_ \n",
"© _CNRS 2016_ - _Inria 2018-2020_ \n",
"_This notebook is an adaptation of a lecture prepared by David Chamont (CNRS) under the terms of the licence [Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)](http://creativecommons.org/licenses/by-nc-sa/4.0/)_ \n",
"_The present version has been written by Sébastien Gilles and Vincent Rouvreau (Inria)_\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "C++17",
"language": "C++17",
"name": "xeus-cling-cpp17"
"name": "xcpp17"
},
"language_info": {
"codemirror_mode": "text/x-c++src",
"file_extension": ".cpp",
"mimetype": "text/x-c++src",
"name": "c++",
"version": "-std=c++17"
"version": "17"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
......@@ -129,5 +136,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
......@@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# [Getting started in C++](/) - [Procedural programming](/notebooks/1-ProceduralProgramming/0-main.ipynb) - [Predefined types](/notebooks/1-ProceduralProgramming/3-Types.ipynb)"
"# [Getting started in C++](/) - [Procedural programming](./0-main.ipynb) - [Predefined types](./3-Types.ipynb)"
]
},
{
......@@ -182,7 +182,7 @@
"metadata": {},
"outputs": [],
"source": [
"int is_positive_p = is_positive::no; // COMPILATION ERROR: not implicitly convertible into an integer"
"int a = is_positive::no; // COMPILATION ERROR: not implicitly convertible into an integer"
]
},
{
......@@ -223,7 +223,9 @@
"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."
"for which you will probably need to go check the prototype to figure out what each argument stands for.\n",
"\n",
"As we shall see [shortly](#Explicit-conversions-by-static_cast), you may perform arithmetic with the underlying integer through _explicit cast_ of the enum into an integer."
]
},
{
......@@ -699,7 +701,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"On such trivial examples it might not seem much, but in practice it might prove incredibly useful. Consider for instance the following C++03 code (the details don't matter: we'll deal with `std::vector` in a [later notebook](/notebooks/5-UsefulConceptsAndSTL/3-Containers.ipynb)):"
"On such trivial examples it might not seem much, but in practice it might prove incredibly useful. Consider for instance the following C++03 code (the details don't matter: we'll deal with `std::vector` in a [later notebook](../5-UsefulConceptsAndSTL/3-Containers.ipynb)):"
]
},
{
......@@ -713,7 +715,7 @@
"\n",
"{\n",
" std::vector<unsigned int> primes { 2, 3, 5, 7, 11, 13, 17, 19 }; // I'm cheating: it's C++ 11 notation...\n",
" // In C++ 03 you would have to push_back one by one each of the element!\n",
" // In C++ 03 you would have to push_back one by one each of the element!\n",
" \n",
" for (std::vector<unsigned int>::const_iterator it = primes.cbegin();\n",
" it != primes.cend();\n",
......@@ -885,7 +887,7 @@
"metadata": {},
"source": [
"\n",
"© _CNRS 2016_ - _Inria 2018-2019_ \n",
"© _CNRS 2016_ - _Inria 2018-2020_ \n",
"_This notebook is an adaptation of a lecture prepared by David Chamont (CNRS) under the terms of the licence [Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)](http://creativecommons.org/licenses/by-nc-sa/4.0/)_ \n",
"_The present version has been written by Sébastien Gilles and Vincent Rouvreau (Inria)_\n",
"\n"
......@@ -896,14 +898,14 @@
"kernelspec": {
"display_name": "C++17",
"language": "C++17",
"name": "xeus-cling-cpp17"
"name": "xcpp17"
},
"language_info": {
"codemirror_mode": "text/x-c++src",
"file_extension": ".cpp",
"mimetype": "text/x-c++src",
"name": "c++",
"version": "-std=c++17"
"version": "17"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
......@@ -938,5 +940,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
......@@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# [Getting started in C++](/) - [Procedural programming](/notebooks/1-ProceduralProgramming/0-main.ipynb) - [Functions](/notebooks/1-ProceduralProgramming/4-Functions.ipynb)"
"# [Getting started in C++](/) - [Procedural programming](./0-main.ipynb) - [Functions](./4-Functions.ipynb)"
]
},
{
......@@ -91,7 +91,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"To reintroduce hierarchy, __namespaces__ can be used (they will be introduced [a bit later](/notebooks/6-InRealEnvironment/5-Namespace.ipynb)); __lambda functions__ introduced later in this notebook are not limited by the same rule."
"To reintroduce hierarchy, __namespaces__ can be used (they will be introduced [a bit later](../6-InRealEnvironment/5-Namespace.ipynb)); __lambda functions__ introduced later in this notebook are not limited by the same rule."
]
},
{
......@@ -173,7 +173,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"As in C++ you can't return several values in the return type, passing by reference is a way to get in output several values (C++ 11 introduced in the standard library a work around to get several values in return type with a so-called `std::tuple`, but the passing by reference remains the better way to do so in most cases)."
"As in C++ you can't return several values in the return type, passing by reference is a way to get in output several values (C++ 11 introduced in the standard library a workaround to get several values in return type with a so-called `std::tuple`, but the passing by reference remains the better way to do so in most cases)."
]
},
{
......@@ -222,7 +222,7 @@
"\n",
"The function above gets two outputs: the quotient and the remainder of the euclidian division. Moreover, this function returns an error code: by convention this function returns 0 when everything is alright and -1 in case of a zero divider. \n",
"\n",
"Using such an error code is a very common pattern in C, that might as well be used in C++... The issue is that it requires a lot of discipline from the user of the function: there are no actual incentive to use the return value! Just calling `compute_division()` as if it was a void function is perfectly fine (and yet completely ill-advised). We will see [later](/notebooks/5-UsefulConceptsAndSTL/1-ErrorHandling.ipynb) the `exception` mechanism C++ recommends instead of error codes.\n",
"Using such an error code is a very common pattern in C, that might as well be used in C++... The issue is that it requires a lot of discipline from the user of the function: there are no actual incentive to use the return value! Just calling `compute_division()` as if it was a void function is perfectly fine (and yet completely ill-advised). We will see [later](../5-UsefulConceptsAndSTL/1-ErrorHandling.ipynb) the `exception` mechanism C++ recommends instead of error codes.\n",
"\n",
"Below is an example where things go awry due to the lack of check:"
]
......@@ -885,7 +885,7 @@
"source": [
"{\n",
" FunctionWithOptional2(3., 5., 6.); // ok\n",
" FunctionWithOptional2(3.); // should be ok, but Xeus-cling issue.\n",
" FunctionWithOptional2(3.); // ok\n",
"}"
]
},
......@@ -1114,7 +1114,7 @@
" \n",
"The syntax to do so is a bit ugly and stems directly from C; it relies upon using a pointer to a function.\n",
"\n",
"The syntax is:\n",
"The syntax looks like:\n",
"\n",
"`unsigned int (*f) (int, double)`\n",
"\n",
......@@ -1181,8 +1181,8 @@
"source": [
"There are other ways to do this task:\n",
"\n",
"* Using a template parameter. Templates will be reached [later in this tutorial](http://localhost:8888/notebooks/4-Templates/0-main.ipynb), but for me it's usually the way to go.\n",
"* Using [functors]()\n",
"* Using a template parameter. Templates will be reached [later in this tutorial](../4-Templates/0-main.ipynb), but for me it's usually the way to go.\n",
"* Using [functors](../3-Operators/5-Functors.ipynb)\n",
"* Using `std::function`, introduced in C++ 11. However <a href=\"https://vittorioromeo.info/index/blog/passing_functions_to_functions.html\">this blog</a> explains why it's not a good idea; on top of the arguments given there it doesn't seem to respect the prototype closely (a function with double instead of int is for instance accepted)."
]
},
......@@ -1258,7 +1258,7 @@
"\n",
"* You have probably notice the conditional in my statements regarding `inline`: the keyword is an _hint_ given to the compiler... that might be followed or not.\n",
"* On the syntactic side, `inline` must be provided both in the declaration `and` the definition.\n",
"* `inline` definitions must be provided in header file (see the [upcoming notebook](/notebooks/6-InRealEnvironment/2-FileStructure.ipynb) that will deal extensively with the file structure to follow in a C++ program). You therefore pay the price in compilation time whenever you change its implementation (as we'll see more in detail in aforementioned notebook, modifying a header file yields more re-compilation).\n",
"* `inline` definitions must be provided in header file (see the [upcoming notebook](../6-InRealEnvironment/2-FileStructure.ipynb) that will deal extensively with the file structure to follow in a C++ program). You therefore pay the price in compilation time whenever you change its implementation (as we'll see more in detail in aforementioned notebook, modifying a header file yields more re-compilation).\n",
"* Don't bother inlining functions with any complexity whatsoever, so if your function includes a loop or is more than few lines long, write a normal function instead. \n",
"\n",
"The `square` example was sound: this is typically the kind of functions that might be inlined."
......@@ -1269,7 +1269,7 @@
"metadata": {},
"source": [
"\n",
"© _CNRS 2016_ - _Inria 2018-2019_ \n",
"© _CNRS 2016_ - _Inria 2018-2020_ \n",
"_This notebook is an adaptation of a lecture prepared by David Chamont (CNRS) under the terms of the licence [Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)](http://creativecommons.org/licenses/by-nc-sa/4.0/)_ \n",
"_The present version has been written by Sébastien Gilles and Vincent Rouvreau (Inria)_\n",
"\n"
......@@ -1280,14 +1280,14 @@
"kernelspec": {
"display_name": "C++17",
"language": "C++17",
"name": "xeus-cling-cpp17"
"name": "xcpp17"
},
"language_info": {
"codemirror_mode": "text/x-c++src",
"file_extension": ".cpp",
"mimetype": "text/x-c++src",
"name": "c++",
"version": "-std=c++17"
"version": "17"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
......@@ -1327,5 +1327,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
......@@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# [Getting started in C++](/) - [Procedural programming](/notebooks/1-ProceduralProgramming/0-main.ipynb) - [Dynamic allocations](/notebooks/1-ProceduralProgramming/5-DynamicAllocation.ipynb)"
"# [Getting started in C++](/) - [Procedural programming](./0-main.ipynb) - [Dynamic allocations](./5-DynamicAllocation.ipynb)"
]
},
{
......@@ -36,7 +36,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
......@@ -79,9 +79,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"5\n"
]
}
],
"source": [
"#include <iostream>\n",
"\n",
......@@ -107,7 +115,7 @@
" \n",
"In sophisticated programs, this could lead in serious and tedious bookkeeping to ensure all variables are properly handled, even if tools such as [Valgrind](http://www.valgrind.org/) or [Address sanitizer](https://github.com/google/sanitizers/wiki/AddressSanitizer) may help to find out those you will probably have forgotten somewhere along the way.\n",
"\n",
"To be honest, C++ gets quite a bad name due to this tedious memory handling; fortunately the RAII idiom provides a neat way to automatize nicely memory management (which we'll study [later](/notebooks/5-UsefulConceptsAndSTL/2-RAII.ipynb)) and some vocal critics on forums that regret the lack of [garbage collection](https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)) might actually not be aware of this fundamental (from my point of view at least) idiom."
"To be honest, C++ gets quite a bad name due to this tedious memory handling; fortunately the RAII idiom provides a neat way to automatize nicely memory management (which we'll study [later](../5-UsefulConceptsAndSTL/2-RAII.ipynb)) and some vocal critics on forums that regret the lack of [garbage collection](https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)) might actually not be aware of this fundamental (from my point of view at least) idiom."
]
},
{
......@@ -186,7 +194,7 @@
"source": [
"that does the exact same job in a shorter way and is much more secure to use.\n",
"\n",
"We shall see `std::vector` more deeply [later](/notebooks/5-UsefulConceptsAndSTL/3-Containers.ipynb) but will nonetheless use it before this as it is a rather elementary brick in most C++ codes."
"We shall see `std::vector` more deeply [later](../5-UsefulConceptsAndSTL/3-Containers.ipynb) but will nonetheless use it before this as it is a rather elementary brick in most C++ codes."
]
},
{
......@@ -194,7 +202,7 @@
"metadata": {},
"source": [
"\n",
"© _CNRS 2016_ - _Inria 2018-2019_ \n",
"© _CNRS 2016_ - _Inria 2018-2020_ \n",
"_This notebook is an adaptation of a lecture prepared by David Chamont (CNRS) under the terms of the licence [Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)](http://creativecommons.org/licenses/by-nc-sa/4.0/)_ \n",
"_The present version has been written by Sébastien Gilles and Vincent Rouvreau (Inria)_\n",
"\n"
......@@ -205,14 +213,14 @@
"kernelspec": {
"display_name": "C++17",
"language": "C++17",
"name": "xeus-cling-cpp17"
"name": "xcpp17"
},
"language_info": {
"codemirror_mode": "text/x-c++src",
"file_extension": ".cpp",
"mimetype": "text/x-c++src",
"name": "c++",
"version": "-std=c++17"
"version": "17"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
......@@ -247,5 +255,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
......@@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# [Getting started in C++](/) - [Procedural programming](/notebooks/1-ProceduralProgramming/0-main.ipynb) - [Input and output streams](/notebooks/1-ProceduralProgramming/6-Streams.ipynb)"
"# [Getting started in C++](/) - [Procedural programming](./0-main.ipynb) - [Input and output streams](./6-Streams.ipynb)"
]
},
{
......@@ -32,9 +32,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello world!\n"
]
}
],
"source": [
"#include <iostream>\n",
"\n",
......@@ -54,9 +62,17 @@
}, <