diff --git a/notebooks/04_Classes+Objects.ipynb b/notebooks/04_Classes+Objects.ipynb
index 2bdb47a22b44ea60d8a1f278cc4fb1ff983a6ca6..b12c155df25e717185c8f8be376b64e27e53a9e5 100644
--- a/notebooks/04_Classes+Objects.ipynb
+++ b/notebooks/04_Classes+Objects.ipynb
@@ -1 +1 @@
-{"metadata":{"orig_nbformat":4,"language_info":{"codemirror_mode":"text/x-c++src","file_extension":".cpp","mimetype":"text/x-c++src","name":"c++","version":"17"},"kernelspec":{"name":"xcpp17","display_name":"C++17","language":"C++17"}},"nbformat_minor":5,"nbformat":4,"cells":[{"cell_type":"markdown","source":"## Classes and Objects\n\nLet's try to implement our first class","metadata":{},"id":"e0e9c863-8720-40a4-a22c-00af773497fe"},{"cell_type":"code","source":"class aggregate {\n    short s = 4;\n    unsigned int i = 1u<<16;\n    double x = 2.0;\n};","metadata":{"trusted":true},"execution_count":1,"outputs":[],"id":"bc685489-cf28-4a15-b0ee-fef2e6143f28"},{"cell_type":"code","source":"#include <iostream>\n\nint main() {\n    aggregate agg;\n    std::cout << \"s = \" << agg.s << std::endl;\n    std::cout << \"i = \" << agg.i << std::endl;\n}","metadata":{"trusted":true},"execution_count":2,"outputs":[{"name":"stderr","text":"input_line_9:3:32: error: 's' is a private member of '__cling_N52::aggregate'\n    std::cout << \"s = \" << agg.s << std::endl;\n                               ^\ninput_line_7:2:11: note: implicitly declared private here\n    short s = 4;\n          ^\ninput_line_9:4:32: error: 'i' is a private member of '__cling_N52::aggregate'\n    std::cout << \"i = \" << agg.i << std::endl;\n                               ^\ninput_line_7:3:18: note: implicitly declared private here\n    unsigned int i = 1u<<16;\n                 ^\n","output_type":"stream"},{"ename":"Interpreter Error","evalue":"","traceback":["Interpreter Error: "],"output_type":"error"}],"id":"4ada47eb-7158-4caf-aa60-0eb8df7e4769"},{"cell_type":"markdown","source":"That did not work. Why?","metadata":{},"id":"4035a6b6-f751-44fa-a579-a1166df4eed7"},{"cell_type":"markdown","source":"Because object-oriented programming is also about **encapsulation**. By making certain attributes (data members) and method (member functions) invisible to the outside, we\n  - can enhance safety: better control over the state of an object\n  - make sure that the internal implementation of the class can be changed without breaking outside code  \n\nIn C++ we have three levels of access:\n  - **public** = any one has access \n  - **private** = only the class itself has access\n  - **protected** = the class and its children have access\n  \nThe difference between a struct and a class lies in their default setting\n\n|            | class | struct |\n|:----------:|:-----:|:------:|\n| default is:|private| public |","metadata":{},"id":"159ef323-6f0a-49af-ac06-98804334e5d1"},{"cell_type":"code","source":"class aggregate {\n  \n  double x;         // private by default\n    \npublic:\n    \n  short s = 4;\n  unsigned int i = 1u<<16;\n\n};\n\nstruct combo {\n  \n  int a;            // public by default\n    \nprivate:\n  int internal;     // not accessible from outside\n\n};","metadata":{"trusted":true},"execution_count":1,"outputs":[],"id":"7ea6dfba-43fe-4730-b845-4bd49c9b3e3a"},{"cell_type":"code","source":"#include <iostream>\n\nint main() {\n  aggregate agg;\n  std::cout << \"s = \" << agg.s << std::endl;\n  std::cout << \"i = \" << agg.i << std::endl;\n\n  combo s;\n  s.a = 7;\n}\n\nmain();","metadata":{"trusted":true},"execution_count":2,"outputs":[{"name":"stdout","text":"s = 4\ni = 65536\n","output_type":"stream"}],"id":"6b4cd5c9-0ec3-451b-95b3-e9ad857eea83"},{"cell_type":"markdown","source":"An **object** is an instance of a class; different objects are different entities.","metadata":{},"id":"8c9241eb-1530-42db-8f50-542b8b74bbb8"},{"cell_type":"code","source":"int main() {\n    \n    aggregate a, b, c;\n    \n    a.s = 1;\n    b.s = 2;\n    c.s = 3;\n    \n    std::cout << \"a's short has a value of \" << a.s << '\\n'\n              << \"b's short has a value of \" << b.s << '\\n'\n              << \"c's short has a value of \" << c.s << std::endl;\n    \n    a = c;\n    std::cout << \"now a.s = \" << a.s << std::endl;\n}","metadata":{"trusted":true},"execution_count":3,"outputs":[],"id":"2f93bb55-528a-4bac-8336-ccf98cc18af0"},{"cell_type":"code","source":"main();","metadata":{"trusted":true},"execution_count":4,"outputs":[{"name":"stdout","text":"a's short has a value of 1\nb's short has a value of 2\nc's short has a value of 3\nnow a.s = 3\n","output_type":"stream"}],"id":"e5ca8f44-4f3f-4142-8b5e-f5a3c31fee7e"},{"cell_type":"markdown","source":"### Constructors\n\n- Our class *aggregate* used *default member initializers* for setting initial values for its data members.\n- This is one possibility. The other is to use a *constructor* and a *member initializer list*.\n- Constructors are also required, if we want to run some start-up code as part of object creation.","metadata":{},"id":"fe29c0f5-6967-403d-b796-779fe1ccf4be"},{"cell_type":"code","source":"#include <iostream>\n\nclass myClass{\n    \n    public:\n        myClass() : memb_(0) {\n            std::cout << \"An instance of myClass was generated.\"\n                      << \" memb_ = \" << memb_ << std::endl;\n        }\n    \n    private:\n        int memb_;    // some people adhere to the convention of marking data members by a trailing \"_\"\n}","metadata":{"trusted":true},"execution_count":5,"outputs":[],"id":"4c961b3c-ba83-46e6-aab1-08f1ad4102e3"},{"cell_type":"code","source":"int main() {\n    myClass myObj;\n}\n\nmain();","metadata":{"trusted":true},"execution_count":6,"outputs":[{"name":"stdout","text":"An instance of myClass was generated. memb_ = 0\n","output_type":"stream"}],"id":"f501dce2-ef23-4345-8072-45ea85cb8c17"},{"cell_type":"markdown","source":"#### Multiple Constructors\nC++ allows to overload functions. One can use this to implement different constructors.","metadata":{},"id":"5a5ded92-91fc-4a2f-8628-d9531cd84ea2"},{"cell_type":"code","source":"class myClass{\n    \n    public:\n        myClass() : memb_(0) {\n            std::cout << \"An instance of myClass was generated.\"\n                      << \" memb_ = \" << memb_ << std::endl;\n        }\n    \n        myClass( int member ) : memb_(member) {\n            std::cout << \"An instance of myClass was generated.\"\n                      << \" memb_ = \" << memb_ << std::endl;\n        }\n    \n    private:\n        int memb_;\n}","metadata":{"trusted":true},"execution_count":7,"outputs":[],"id":"3f4cf1f6-8c50-4057-ab71-259c1046222a"},{"cell_type":"code","source":"int main() {\n    myClass myObj1;\n    myClass myObj2( 5 );\n}\n\nmain();","metadata":{"trusted":true},"execution_count":8,"outputs":[{"name":"stdout","text":"An instance of myClass was generated. memb_ = 0\nAn instance of myClass was generated. memb_ = 5\n","output_type":"stream"}],"id":"51015ed7-9f4e-40c0-bfa9-2b9f98cd0e1e"},{"cell_type":"markdown","source":"#### Constructor Delegation","metadata":{},"id":"ee95a999-1b5a-4c1b-b2a3-d7dc9a6b306f"},{"cell_type":"markdown","source":"In the example above the body of both constructors is identical. Such a code duplication is, of course, not nice and in violation of the **D**on't **R**epeat **Y**ourself principle. We can avoid this by using **constructor delegation**.","metadata":{},"id":"b977d057-634f-4027-a177-6866bf88160b"},{"cell_type":"code","source":"#include <iostream>\n\nclass myClass{\n    \n    public:\n        myClass( int member ) : memb_(member) {\n            std::cout << \"An instance of myClass was generated.\"\n                      << \" memb_ = \" << memb_ << std::endl;\n        }\n\n        myClass() : myClass(0) {}\n        \n    private:\n        int memb_;\n};","metadata":{"trusted":true},"execution_count":9,"outputs":[],"id":"8eed6ec9-9ad6-48ab-b0e2-ab0ea35b9b57"},{"cell_type":"markdown","source":"#### Cleaning up: Destructors\nWhen an object goes out of scope and is destroyed we might want or need to do some housekeeping. For this we can implement a destructor.","metadata":{},"id":"fa5b47ea-8d12-4f55-8efe-c08588b81dbc"},{"cell_type":"code","source":"#include <iostream>\n\nclass VerboseClass{\n    \n    public:\n        // c'tor\n        VerboseClass() {\n            std::cout << \"An instance of VerboseClass was generated.\" << std::endl;\n        }\n\n        // d'tor\n        ~VerboseClass() {\n            std::cout << \"An instance of VerboseClass was destroyed.\\n\" << std::endl;\n        }\n};","metadata":{"trusted":true},"execution_count":10,"outputs":[],"id":"e456ce69-71e5-4169-b3e8-f302c3f72242"},{"cell_type":"code","source":"int main() {\n    for( int k = 0; k < 3; k++ ) {\n        VerboseClass talky;\n    }\n}\n\nmain();","metadata":{"trusted":true},"execution_count":11,"outputs":[{"name":"stdout","text":"An instance of VerboseClass was generated.\nAn instance of VerboseClass was destroyed.\n\nAn instance of VerboseClass was generated.\nAn instance of VerboseClass was destroyed.\n\nAn instance of VerboseClass was generated.\nAn instance of VerboseClass was destroyed.\n\n","output_type":"stream"}],"id":"8fe56e9c-1842-4c29-84eb-1b20b3f7704a"},{"cell_type":"markdown","source":"#### Small Project: A Vector Class for Linear Algebra\nTasks:\n- We want to implement a class that represents a vector entity from linear algebra.\n- The size of the vector should be selectable at object creation -> need to allocate memory dynamically.\n- Access to vector entries should be 1-based -> operator overloading.\n- Implement simple methods, such as\n  - scaling vector with a constant\n  - adding two vectors together\n  - compute the Euclidean inner product of two vectors","metadata":{},"id":"dffe4043-6959-4169-b0df-203a50d36e0f"},{"cell_type":"code","source":"// --------------------------------------\n//  Start with the skeleton of the class\n// --------------------------------------\n\n#include <iostream>\n#include <cassert>\n\nclass VectorClass{\n    \n    public:\n    \n        // User should specify dimension at object creation\n        VectorClass( unsigned int dim ) : dim_(dim) {\n            \n            // don't allow vectors with zero dimension\n            assert( dim_ > 0 );\n\n            // allocate memory (will throw an exception, if it fails)\n            vec_ = new double[ dim_ ];\n            \n            // be talkative ;-)\n            std::cout << \"An instance of VectorClass was generated. dim_ = \" << dim_ << std::endl;\n        }\n\n        // Don't allow the default constructor [prior to C++11 you would solve this by making it private]\n        VectorClass() = delete;\n\n    private:\n        unsigned int dim_;   // dimension of vector\n        double* vec_;        // entries of vector\n};","metadata":{"trusted":true},"execution_count":12,"outputs":[],"id":"f33e5eef-b396-4bfc-8031-f21b33839611"},{"cell_type":"code","source":"int main() {\n    VectorClass myVec( 10 );\n}","metadata":{"trusted":true},"execution_count":13,"outputs":[],"id":"e2f2ac16-a0df-4f6c-816a-cb47420f4989"},{"cell_type":"code","source":"main();","metadata":{"trusted":true},"execution_count":14,"outputs":[{"name":"stdout","text":"An instance of VectorClass was generated. dim_ = 10\n","output_type":"stream"}],"id":"7c06f924-8412-449c-a5b5-a56b1df2ff2b"},{"cell_type":"markdown","source":"Our implementation is **missing an essential piece**? What could that be?","metadata":{},"id":"935b6f8d-d347-4edb-9807-f2ed3563dcaf"},{"cell_type":"code","source":"// --------------------------------------\n//  Start with the skeleton of the class\n// --------------------------------------\n\n#include <iostream>\n#include <cassert>\n\nclass VectorClass{\n    \n    public:\n    \n        // User should specify dimension at object creation\n        VectorClass( unsigned int dim ) : dim_(dim) {\n            \n            // don't allow vectors with zero dimension\n            assert( dim_ > 0 );\n\n            // allocate memory (will throw an exception, if it fails)\n            vec_ = new double[ dim_ ];\n            \n            // be talkative ;-)\n            std::cout << \"An instance of VectorClass was generated. dim_ = \" << dim_ << std::endl;\n        }\n\n        // Don't allow the default constructor [prior to C++11 you would solve this by making it private]\n        VectorClass() = delete;\n    \n        // We need to implement a destructor to free the dynamic memory again, otherwise we easily produce\n        // memory leaks\n        ~VectorClass() {\n            delete[] vec_;\n            std::cout << \"An instance of VectorClass was destroyed and \" << dim_ * sizeof(double)\n                      << \" bytes freed.\" << std::endl;\n        }\n\n    private:\n        unsigned int dim_;   // dimension of vector\n        double* vec_;        // entries of vector\n};","metadata":{"trusted":true},"execution_count":15,"outputs":[],"id":"102897af-957e-43b7-a959-eb6ee468f35d"},{"cell_type":"code","source":"int main() {\n    VectorClass myVec( 10 );\n}\n\nmain();","metadata":{"trusted":true},"execution_count":16,"outputs":[{"name":"stdout","text":"An instance of VectorClass was generated. dim_ = 10\nAn instance of VectorClass was destroyed and 80 bytes freed.\n","output_type":"stream"}],"id":"adcac578-0bca-4aed-8d13-4514826dd0e7"},{"cell_type":"markdown","source":"Our VectorClass is currently pretty useless, since we cannot manipulate the values of the vector entries. Making vec_ public would break encapsulation. Instead let's\n- overload the [ ] for providing one-based access\n- add a getter method for the dimension\n- add a member function to pretty-print the vector's entries","metadata":{},"id":"1a74105b-5453-49ab-aeed-e0371809fc52"},{"cell_type":"code","source":"#include <iostream>\n#include <cassert>\n\nclass VectorClass{\n    \n    public:\n    \n        // User should specify dimension at object creation\n        VectorClass( unsigned int dim ) : dim_(dim) {\n            \n            // don't allow vectors with zero dimension\n            assert( dim_ > 0 );\n\n            // allocate memory (will throw an exception, if it fails)\n            vec_ = new double[ dim_ ];\n            \n            // be talkative ;-)\n            std::cout << \"An instance of VectorClass was generated. dim_ = \" << dim_ << std::endl;\n        }\n\n        // Don't allow the default constructor [prior to C++11 you would solve this by making it private]\n        VectorClass() = delete;\n    \n        // We need to implement a destructor to free the dynamic memory again, otherwise we easily produce\n        // memory leaks\n        ~VectorClass() {\n            delete[] vec_;\n            std::cout << \"An instance of VectorClass was destroyed and \" << dim_ * sizeof(double)\n                      << \" bytes freed.\" << std::endl;\n        }\n\n        // provide access to the vector's dimension\n        unsigned int getDim() { return dim_; }\n    \n        // overload the [] for accessing individual entries\n        double& operator[] ( unsigned int index ){\n            assert( index != 0 && index <= dim_ );\n            return vec_[index-1];\n        }\n\n        // pretty print vector to given output stream\n        void print( std::ostream &os ) {\n            os << \"(\";\n            for( unsigned int k = 0; k < dim_-1; k++ ) {\n                os << vec_[k] << \", \";\n            }\n            os << vec_[dim_-1] << \")\" << std::endl;\n        }\n    \n    private:\n        unsigned int dim_;   // dimension of vector\n        double* vec_;        // entries of vector\n\n};","metadata":{"trusted":true},"execution_count":17,"outputs":[],"id":"a32eb08a-822a-4b83-b3d0-6de281acffba"},{"cell_type":"code","source":"// Let's test our extended class\n\nint main() {\n    \n    VectorClass myVec( 3 );\n    \n    myVec[ 1 ] = 3.0;\n    myVec[ 2 ] = 2.0;\n    myVec[ 3 ] = 1.0;\n    \n    myVec.print( std::cout );\n}\n\nmain();","metadata":{"trusted":true},"execution_count":18,"outputs":[{"name":"stdout","text":"An instance of VectorClass was generated. dim_ = 3\n(3, 2, 1)\nAn instance of VectorClass was destroyed and 24 bytes freed.\n","output_type":"stream"}],"id":"4eb50e73-21f5-4669-9464-32f11d958732"},{"cell_type":"markdown","source":"**What is left on our todo-list?**\nImplement simple methods, such as\n  - scaling vector with a constant\n  - adding two vectors together\n  - compute the Euclidean inner product of two vectors","metadata":{},"id":"d8af8c97-2855-41f9-bda2-9d5ae341b7c0"},{"cell_type":"code","source":"%%file VectorClass.cpp\n\n#include <iostream>\n#include <cassert>\n\nclass VectorClass{\n    \n    public:\n    \n        // User should specify dimension at object creation\n        VectorClass( unsigned int dim ) : dim_(dim) {\n            \n            // don't allow vectors with zero dimension\n            assert( dim_ > 0 );\n\n            // allocate memory (will throw an exception, if it fails)\n            vec_ = new double[ dim_ ];\n            \n            // be talkative ;-)\n            std::cout << \"An instance of VectorClass was generated. dim_ = \" << dim_ << std::endl;\n        }\n\n        // Don't allow the default constructor [prior to C++11 you would solve this by making it private]\n        VectorClass() = delete;\n    \n        // We need to implement a destructor to free the dynamic memory again, otherwise we easily produce\n        // memory leaks\n        ~VectorClass() {\n            delete[] vec_;\n            std::cout << \"An instance of VectorClass was destroyed and \" << dim_ * sizeof(double)\n                      << \" bytes freed.\" << std::endl;\n        }\n\n        // provide access to the vector's dimension\n        unsigned int getDim() { return dim_; }\n    \n        // overload the [] for accessing individual entries\n        double& operator[] ( unsigned int index ){\n            assert( index != 0 && index <= dim_ );\n            return vec_[index-1];\n        }\n\n        // pretty print vector to given output stream (default will be std::cout)\n        void print( std::ostream &os = std::cout ) {\n            os << \"(\";\n            for( unsigned int k = 0; k < dim_-1; k++ ) {\n                os << vec_[k] << \", \";\n            }\n            os << vec_[dim_-1] << \")\" << std::endl;\n        }\n    \n        // scale vector with a constant\n        void scale( double factor ) {\n            // leave that to students\n        }\n    \n        // add to vectors together (that's actually a little bit tricky, due to the question \"where to put the result?\"\n        // for the moment leave it with adding another vector to the one on which the method is called.\n    \n        // let us try the following, and determine, why it will fail ;-)\n        void add( VectorClass other ) {\n\n            // make sure that input vector has correct length\n            assert( other.getDim() == dim_ );\n            for( unsigned int k = 0; k < dim_; k++ ) {\n                vec_[k] += other[k+1];\n            }\n            //for( unsigned int k = 1; k <= dim_; k++ ) {\n            //    this->operator[](k) += other[k];\n            //}\n        }\n    \n    private:\n        unsigned int dim_;   // dimension of vector\n        double* vec_;        // entries of vector\n\n};\n\n// Modify driver a little bit\nint main() {\n\n    const unsigned int dim = 10;\n  \n    // set up 1st vector\n    VectorClass myVec( dim );\n    for( unsigned int idx = 1; idx <= dim; idx ++ ) {\n      myVec[ idx ] = static_cast<double>( dim - idx + 1 );\n    }\n    myVec.print( std::cout );\n    \n    // set up 2nd vector\n    VectorClass second( dim );\n    for( unsigned int idx = 1; idx <= dim; idx ++ ) {\n      second[ idx ] = static_cast<double>( idx );\n    }\n    second.print( std::cout );\n    \n    // add the 2nd to the 1st\n    myVec.add( second );\n    myVec.print();\n}","metadata":{"trusted":true},"execution_count":19,"outputs":[{"name":"stdout","text":"Overwriting VectorClass.cpp\n","output_type":"stream"}],"id":"cdfde2f9-fafc-4a9f-99b7-4952720e4521"},{"cell_type":"code","source":"!g++ -g VectorClass.cpp","metadata":{"trusted":true},"execution_count":20,"outputs":[],"id":"f9331dc3-19ff-44a2-a8f5-6e258f9266d2"},{"cell_type":"code","source":"!./a.out","metadata":{"trusted":true},"execution_count":21,"outputs":[{"name":"stdout","text":"An instance of VectorClass was generated. dim_ = 10\n(10, 9, 8, 7, 6, 5, 4, 3, 2, 1)\nAn instance of VectorClass was generated. dim_ = 10\n(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)\nAn instance of VectorClass was destroyed and 80 bytes freed.\n(11, 11, 11, 11, 11, 11, 11, 11, 11, 11)\nfree(): double free detected in tcache 2\nAborted (core dumped)\n","output_type":"stream"}],"id":"4f4d196d-761d-40e1-9d08-5df87307476b"},{"cell_type":"markdown","source":"**Note**: The adding itself seems to have worked correctly, but somehow we still have a problem. So what's wrong here?","metadata":{},"id":"3e04234e-4f33-44c4-9adb-0bde893019df"},{"cell_type":"markdown","source":"The answer to this is multifaceted:\n- Our implementation of *add()* used **call-by-copy**\n- Since we pass an object, its **copy constructor** is invoked\n- We haven't implemented one, but the compiler did automatically (thank's for that ;-)\n- Thus, the copy we get of **other** is a **flat** one!","metadata":{},"id":"7551ddc3-e449-47f1-bdc8-9a8080acdaf9"},{"cell_type":"markdown","source":"***\nWe can check on that by making the destructor tell us which block it is going to deallocate and run our code through valgrind:\n***\n**==> valgrind ./a.out**\n<div>\n==28488== Memcheck, a memory error detector</br>\n==28488== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.</br>\n==28488== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info</br>\n==28488== Command: ./a.out</br>\n==28488== </br>\nAn instance of VectorClass was generated. dim_ = 10</br>\n(10, 9, 8, 7, 6, 5, 4, 3, 2, 1)</br>\nAn instance of VectorClass was generated. dim_ = 10</br>\n(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)</br>\n<font color=\"red\">Going to delete memory starting at address 0x4d9b150</font></br>\nAn instance of VectorClass was destroyed and 80 bytes freed.</br>\n(11, 11, 11, 11, 11, 11, 11, 11, 11, 11)</br>\n<font color=\"red\">Going to delete memory starting at address 0x4d9b150</font></br>\n==28488== Invalid free() / delete / delete[] / realloc()</br>\n==28488==    at 0x483758B: operator delete[](void*) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)</br>\n==28488==    by 0x109500: VectorClass::~VectorClass() (VectorClass3.cpp:30)</br>\n==28488==    by 0x109341: main (VectorClass3.cpp:93)</br>\n==28488==  Address 0x4d9b150 is 0 bytes inside a block of size 80 free'd</br>\n==28488==    at 0x483758B: operator delete[](void*) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)</br>\n==28488==    by 0x109500: VectorClass::~VectorClass() (VectorClass3.cpp:30)</br>\n==28488==    by 0x109322: main (VectorClass3.cpp:100)</br>\n==28488==  Block was alloc'd at</br>\n==28488==    at 0x483650F: operator new[](unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)</br>\n==28488==    by 0x109450: VectorClass::VectorClass(unsigned int) (VectorClass3.cpp:15)</br>\n==28488==    by 0x109291: main (VectorClass3.cpp:93)</br>\n==28488== </br>\nAn instance of VectorClass was destroyed and 80 bytes freed.</br>\nGoing to delete memory starting at address 0x4d9ac80</br>\nAn instance of VectorClass was destroyed and 80 bytes freed.</br>\n==28488== </br>\n==28488== HEAP SUMMARY:</br>\n==28488==     in use at exit: 0 bytes in 0 blocks</br>\n==28488==   total heap usage: 4 allocs, 5 frees, 73,888 bytes allocated</br>\n==28488== </br>\n==28488== All heap blocks were freed -- no leaks are possible</br>\n==28488== </br>\n==28488== For counts of detected and suppressed errors, rerun with: -v</br>\n==28488== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)</br>\n</div>","metadata":{},"id":"02714f7e-52c4-4890-8a87-05ca91d651e5"},{"cell_type":"markdown","source":"Another way to check on this is to remove the automatic copy constructor","metadata":{},"id":"48d75c49-dd79-420e-9e00-c75865245b5c"},{"cell_type":"code","source":"%%file VectorClass.cpp\n\n#include <iostream>\n#include <cassert>\n\nclass VectorClass{\n    \n    public:\n    \n        // User should specify dimension at object creation\n        VectorClass( unsigned int dim ) : dim_(dim) {\n            \n            // don't allow vectors with zero dimension\n            assert( dim_ > 0 );\n\n            // allocate memory (will throw an exception, if it fails)\n            vec_ = new double[ dim_ ];\n            \n            // be talkative ;-)\n            std::cout << \"An instance of VectorClass was generated. dim_ = \" << dim_ << std::endl;\n        }\n\n        // Don't allow the default constructor [prior to C++11 you would solve this by making it private]\n        VectorClass() = delete;\n\n        // Don't allow the following default copy constructor either\n        VectorClass( VectorClass &other ) = delete;\n    \n        // We need to implement a destructor to free the dynamic memory again, otherwise we easily produce\n        // memory leaks\n        ~VectorClass() {\n            delete[] vec_;\n            std::cout << \"An instance of VectorClass was destroyed and \" << dim_ * sizeof(double)\n                      << \" bytes freed.\" << std::endl;\n        }\n\n        // provide access to the vector's dimension\n        unsigned int getDim() { return dim_; }\n    \n        // overload the [] for accessing individual entries\n        double& operator[] ( unsigned int index ){\n            assert( index != 0 && index <= dim_ );\n            return vec_[index-1];\n        }\n\n        // pretty print vector to given output stream (default will be std::cout)\n        void print( std::ostream &os = std::cout ) {\n            os << \"(\";\n            for( unsigned int k = 0; k < dim_-1; k++ ) {\n                os << vec_[k] << \", \";\n            }\n            os << vec_[dim_-1] << \")\" << std::endl;\n        }\n    \n        // scale vector with a constant\n        void scale( double factor ) {\n            // leave that to students\n        }\n    \n        // add to vectors together (that's actually a little bit tricky, due to the question \"where to put the result?\"\n        // for the moment leave it with adding another vector to the one on which the method is called.\n    \n        // let us try the following, and determine, why it will fail ;-)\n        void add( VectorClass other ) {\n\n            // make sure that input vector has correct length\n            assert( other.getDim() == dim_ );\n            // for( unsigned int k = 0; k < dim_; k++ ) {\n            //     vec_[k] += other[k+1];\n            // }\n            for( unsigned int k = 1; k <= dim_; k++ ) {\n                this->operator[](k) += other[k];\n            }\n        }\n    \n    private:\n        unsigned int dim_;   // dimension of vector\n        double* vec_;        // entries of vector\n\n};\n\n// Modify driver a little bit\nint main() {\n\n    const unsigned int dim = 10;\n  \n    // set up 1st vector\n    VectorClass myVec( dim );\n    for( unsigned int idx = 1; idx <= dim; idx ++ ) {\n      myVec[ idx ] = static_cast<double>( dim - idx + 1 );\n    }\n    myVec.print( std::cout );\n    \n    // set up 2nd vector\n    VectorClass other( dim );\n    for( unsigned int idx = 1; idx <= dim; idx ++ ) {\n      other[ idx ] = static_cast<double>( idx );\n    }\n    other.print( std::cout );\n    \n    // add the 2nd to the 1st\n    myVec.add( other );\n    myVec.print();\n}","metadata":{"trusted":true},"execution_count":22,"outputs":[{"name":"stdout","text":"Overwriting VectorClass.cpp\n","output_type":"stream"}],"id":"def80c0f-89b6-4e00-995a-14b8e800975c"},{"cell_type":"code","source":"!g++ VectorClass.cpp","metadata":{"trusted":true},"execution_count":23,"outputs":[{"name":"stdout","text":"VectorClass.cpp: In function ‘int main()’:\nVectorClass.cpp:101:22: error: use of deleted function ‘VectorClass::VectorClass(VectorClass&)’\n     myVec.add( other );\n                      ^\nVectorClass.cpp:26:9: note: declared here\n         VectorClass( VectorClass &other ) = delete;\n         ^~~~~~~~~~~\nVectorClass.cpp:63:14: note:   initializing argument 1 of ‘void VectorClass::add(VectorClass)’\n         void add( VectorClass other ) {\n              ^~~\n","output_type":"stream"}],"id":"473de9eb-b04c-4087-8444-8d4b3c4c9fb8"},{"cell_type":"markdown","source":"#### Solution?\nHow should we resolve the issue?\n***\nFor the current case the best solution is to change the interface of our `add()` method to be\n\n`void add( const VectorClass& other )`\n\nThe `const` is no must, but makes it clear to other programmers and the compiler that we are not going to change the object\nother inside add().","metadata":{},"id":"91724843-2e97-4862-888a-291fda71444a"},{"cell_type":"code","source":"#include <iostream>\n#include <cassert>\n\nclass VectorClass{\n    \n    public:\n    \n        // User should specify dimension at object creation\n        VectorClass( unsigned int dim ) : dim_(dim) {\n            \n            // don't allow vectors with zero dimension\n            assert( dim_ > 0 );\n\n            // allocate memory (will throw an exception, if it fails)\n            vec_ = new double[ dim_ ];\n            \n            // be talkative ;-)\n            std::cout << \"An instance of VectorClass was generated. dim_ = \" << dim_ << std::endl;\n        }\n\n        // Don't allow the default constructor [prior to C++11 you would solve this by making it private]\n        VectorClass() = delete;\n\n        // Don't allow the following default copy constructor either\n        VectorClass( VectorClass &other ) = delete;\n    \n        // We need to implement a destructor to free the dynamic memory again, otherwise we easily produce\n        // memory leaks\n        ~VectorClass() {\n            delete[] vec_;\n            std::cout << \"An instance of VectorClass was destroyed and \" << dim_ * sizeof(double)\n                      << \" bytes freed.\" << std::endl;\n        }\n\n        // provide access to the vector's dimension\n        unsigned int getDim() { return dim_; }\n    \n        // overload the [] for accessing individual entries\n        double& operator[] ( unsigned int index ){\n            assert( index != 0 && index <= dim_ );\n            return vec_[index-1];\n        }\n\n        // pretty print vector to given output stream (default will be std::cout)\n        void print( std::ostream &os = std::cout ) {\n            os << \"(\";\n            for( unsigned int k = 0; k < dim_-1; k++ ) {\n                os << vec_[k] << \", \";\n            }\n            os << vec_[dim_-1] << \")\" << std::endl;\n        }\n    \n        // scale vector with a constant\n        void scale( double factor ) {\n            // leave that to students\n        }\n    \n        // add to vectors together (that's actually a little bit tricky, due to the question \"where to put the result?\"\n        // for the moment leave it with adding another vector to the one on which the method is called.\n    \n        // let us try the following, and determine, why it will fail ;-)\n        void add( const VectorClass& other ) {\n\n            // make sure that input vector has correct length\n            assert( other.getDim() == dim_ );\n            // for( unsigned int k = 0; k < dim_; k++ ) {\n            //     vec_[k] += other[k+1];\n            // }\n            for( unsigned int k = 1; k <= dim_; k++ ) {\n                this->operator[](k) += other[k];\n            }\n        }\n    \n    private:\n        unsigned int dim_;   // dimension of vector\n        double* vec_;        // entries of vector\n\n};\n\n// Modify driver a little bit\nint main() {\n\n    const unsigned int dim = 10;\n  \n    // set up 1st vector\n    VectorClass myVec( dim );\n    for( unsigned int idx = 1; idx <= dim; idx ++ ) {\n      myVec[ idx ] = static_cast<double>( dim - idx + 1 );\n    }\n    myVec.print( std::cout );\n    \n    // set up 2nd vector\n    VectorClass other( dim );\n    for( unsigned int idx = 1; idx <= dim; idx ++ ) {\n      other[ idx ] = static_cast<double>( idx );\n    }\n    other.print( std::cout );\n    \n    // add the 2nd to the 1st\n    myVec.add( other );\n    myVec.print();\n}","metadata":{"trusted":true},"execution_count":24,"outputs":[{"name":"stderr","text":"input_line_35:61:45: error: no viable overloaded operator[] for type 'const VectorClass'\n                this->operator[](k) += other[k];\n                                       ~~~~~^~\ninput_line_35:32:17: note: candidate function not viable: 'this' argument has type 'const VectorClass', but method is not marked const\n        double& operator[] ( unsigned int index ){\n                ^\ninput_line_35:71:13: error: function definition is not allowed here\n int main() {\n            ^\n","output_type":"stream"},{"ename":"Interpreter Error","evalue":"","traceback":["Interpreter Error: "],"output_type":"error"}],"id":"30eccd22-8c5e-4062-a1d1-8006981aae99"},{"cell_type":"markdown","source":"***\nAh, okay. So the `const` was a good idea, but requires a little bit of extra work!\n\nWe need to implement a second version of the operator overloading that returns a const reference!","metadata":{},"id":"a6bfec6d-9eba-4e34-9ec8-e74bfa485664"},{"cell_type":"code","source":"#include <iostream>\n#include <cassert>\n\nclass VectorClass{\n    \n    public:\n    \n        // User should specify dimension at object creation\n        VectorClass( unsigned int dim ) : dim_(dim) {\n            \n            // don't allow vectors with zero dimension\n            assert( dim_ > 0 );\n\n            // allocate memory (will throw an exception, if it fails)\n            vec_ = new double[ dim_ ];\n            \n            // be talkative ;-)\n            std::cout << \"An instance of VectorClass was generated. dim_ = \" << dim_ << std::endl;\n        }\n\n        // Don't allow the default constructor [prior to C++11 you would solve this by making it private]\n        VectorClass() = delete;\n\n        // Don't allow the following default copy constructor either\n        VectorClass( VectorClass &other ) = delete;\n    \n        // We need to implement a destructor to free the dynamic memory again, otherwise we easily produce\n        // memory leaks\n        ~VectorClass() {\n            delete[] vec_;\n            std::cout << \"An instance of VectorClass was destroyed and \" << dim_ * sizeof(double)\n                      << \" bytes freed.\" << std::endl;\n        }\n\n        // provide access to the vector's dimension\n        unsigned int getDim() { return dim_; }\n    \n        // overload the [] for accessing individual entries\n        double& operator[] ( unsigned int index ){\n            assert( index != 0 && index <= dim_ );\n            return vec_[index-1];\n        }\n    \n        // overload the [] for accessing individual entries\n        const double& operator[] ( unsigned int index ) {\n            assert( index != 0 && index <= dim_ );\n            return vec_[index-1];\n        }\n    \n        // pretty print vector to given output stream (default will be std::cout)\n        void print( std::ostream &os = std::cout ) {\n            os << \"(\";\n            for( unsigned int k = 0; k < dim_-1; k++ ) {\n                os << vec_[k] << \", \";\n            }\n            os << vec_[dim_-1] << \")\" << std::endl;\n        }\n    \n        // scale vector with a constant\n        void scale( double factor ) {\n            // leave that to students\n        }\n    \n        // add to vectors together (that's actually a little bit tricky, due to the question \"where to put the result?\"\n        // for the moment leave it with adding another vector to the one on which the method is called.\n    \n        // let us try the following, and determine, why it will fail ;-)\n        void add( const VectorClass& other ) {\n\n            // make sure that input vector has correct length\n            assert( other.getDim() == dim_ );\n            // for( unsigned int k = 0; k < dim_; k++ ) {\n            //     vec_[k] += other[k+1];\n            // }\n            for( unsigned int k = 1; k <= dim_; k++ ) {\n                this->operator[](k) += other[k];\n            }\n        }\n    \n    private:\n        unsigned int dim_;   // dimension of vector\n        double* vec_;        // entries of vector\n\n};\n\n// Modify driver a little bit\nint main() {\n\n    const unsigned int dim = 10;\n  \n    // set up 1st vector\n    VectorClass myVec( dim );\n    for( unsigned int idx = 1; idx <= dim; idx ++ ) {\n      myVec[ idx ] = static_cast<double>( dim - idx + 1 );\n    }\n    myVec.print( std::cout );\n    \n    // set up 2nd vector\n    VectorClass other( dim );\n    for( unsigned int idx = 1; idx <= dim; idx ++ ) {\n      other[ idx ] = static_cast<double>( idx );\n    }\n    other.print( std::cout );\n    \n    // add the 2nd to the 1st\n    myVec.add( other );\n    myVec.print();\n}","metadata":{"trusted":true},"execution_count":25,"outputs":[{"name":"stderr","text":"input_line_37:38:23: error: functions that differ only in their return type cannot be overloaded\n        const double& operator[] ( unsigned int index ) {\n              ~~~~~~~ ^\ninput_line_37:32:17: note: previous definition is here\n        double& operator[] ( unsigned int index ){\n        ~~~~~~~ ^\ninput_line_37:68:45: error: no viable overloaded operator[] for type 'const VectorClass'\n                this->operator[](k) += other[k];\n                                       ~~~~~^~\ninput_line_37:32:17: note: candidate function not viable: 'this' argument has type 'const VectorClass', but method is not marked const\n        double& operator[] ( unsigned int index ){\n                ^\ninput_line_37:78:13: error: function definition is not allowed here\n int main() {\n            ^\n","output_type":"stream"},{"ename":"Interpreter Error","evalue":"","traceback":["Interpreter Error: "],"output_type":"error"}],"id":"15b02a70-a496-4098-a446-9a60ee30b116"},{"cell_type":"markdown","source":"Shoot, we have a problem with the **signature** now!\n\nBut, fortunately, there is a way out of this:\n- We can tell the compiler that a member function does not alter its object! This will also be part of the signature. So we can implement our overloading as\n`const double& operator[] ( unsigned int index ) const`\n- We might want to do this also for any other member function that does not change the object, like e.g. `print()`\n\nIf we do this, we end up with the final version:","metadata":{},"id":"6a78d290-77dc-43a5-93f5-15fa2c650ddb"},{"cell_type":"code","source":"#include <iostream>\n#include <cassert>\n\nclass VectorClass {\n    \npublic:\n    \n  // User should specify dimension at object creation\n  VectorClass( unsigned int dim ) : dim_(dim) {\n            \n    // don't allow vectors with zero dimension\n    assert( dim_ > 0 );\n\n    // allocate memory (will throw an exception, if it fails)\n    vec_ = new double[ dim_ ];\n            \n    // be talkative ;-)\n    std::cout << \"An instance of VectorClass was generated. dim_ = \" \n              << dim_ << std::endl;\n  }\n\n  // Don't allow the default constructor\n  // [prior to C++11 you would solve this by making it private]\n  VectorClass() = delete;\n\n  // Don't allow the following default copy constructor either    \n  VectorClass( VectorClass &other ) = delete;\n \n  // We need to implement a destructor to free the dynamic memory again,\n  // otherwise we easily produce memory leaks\n  ~VectorClass() {\n    std::cout << \"Going to delete memory starting at address \"\n              << vec_ << std::endl;\n          \n    delete[] vec_;\n    std::cout << \"An instance of VectorClass was destroyed and \"\n              << dim_ * sizeof(double)\n              << \" bytes freed.\" << std::endl;\n  }\n\n  // provide access to the vector's dimension\n  unsigned int getDim() const { return dim_; }\n    \n  // overload the [] for accessing individual entries\n  double& operator[] ( unsigned int index ) {\n    assert( index != 0 && index <= dim_ );\n    return vec_[index-1];\n  }\n\n  const double& operator[] ( unsigned int index ) const {\n    assert( index != 0 && index <= dim_ );\n    return vec_[index-1];\n  }\n\n  // pretty print vector to given output stream (default will be std::cout)\n  void print( std::ostream &os = std::cout ) const {\n    os << \"(\";\n    for( unsigned int k = 0; k < dim_-1; k++ ) {\n      os << vec_[k] << \", \";\n    }\n    os << vec_[dim_-1] << \")\" << std::endl;\n  }\n    \n  // scale vector with a constant\n  void scale( double factor ) {\n    // leave that to students\n  }\n    \n  // add to vectors together (that's actually a little bit tricky,\n  // due to the question \"where to put the result?\"\n  // for the moment leave it with adding another vector to the one on which\n  // the method is called.\n  void add( const VectorClass& other ) {\n\n    // make sure that input vector has correct length\n    assert( other.getDim() == dim_ );\n    // for( unsigned int k = 0; k < dim_; k++ ) {\n    //     vec_[k] += other[k+1];\n    // }\n    for( unsigned int k = 1; k <= dim_; k++ ) {\n      this->operator[](k) += other[k];\n    }\n  }\n    \nprivate:\n  unsigned int dim_;   // dimension of vector\n  double* vec_;        // entries of vector\n\n};","metadata":{"trusted":true},"execution_count":1,"outputs":[],"id":"0b2a852d-2a07-4f2a-85d2-7833051474d7"},{"cell_type":"code","source":"int main() {\n\n    const unsigned int dim = 10;\n  \n    // set up 1st vector\n    VectorClass myVec( dim );\n    for( unsigned int idx = 1; idx <= dim; idx ++ ) {\n      myVec[ idx ] = static_cast<double>( dim - idx + 1 );\n    }\n    myVec.print( std::cout );\n    \n    // set up 2nd vector\n    VectorClass other( dim );\n    for( unsigned int idx = 1; idx <= dim; idx ++ ) {\n      other[ idx ] = static_cast<double>( idx );\n    }\n    other.print( std::cout );\n    \n    // add the 2nd to the 1st\n    myVec.add( other );\n    myVec.print();\n}","metadata":{"trusted":true},"execution_count":2,"outputs":[],"id":"81aeb13c-be8f-4e15-b7d7-acffb4a575eb"},{"cell_type":"code","source":"main();","metadata":{"trusted":true},"execution_count":3,"outputs":[{"name":"stdout","text":"An instance of VectorClass was generated. dim_ = 10\n(10, 9, 8, 7, 6, 5, 4, 3, 2, 1)\nAn instance of VectorClass was generated. dim_ = 10\n(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)\n(11, 11, 11, 11, 11, 11, 11, 11, 11, 11)\nGoing to delete memory starting at address 0x55fe4d219080\nAn instance of VectorClass was destroyed and 80 bytes freed.\nGoing to delete memory starting at address 0x55fe4d6ad9c0\nAn instance of VectorClass was destroyed and 80 bytes freed.\n","output_type":"stream"}],"id":"77177a38-424a-4558-8836-9c6f95bdd7c0"},{"cell_type":"markdown","source":"***\n#### Separating Implementation and Interface\n\n- Assume that we have the definition of a `class A` in one source file and want to use the class in another source file `B.cpp`.\n- For this the compiler needs to known at least that `class A` exists:  \n  This can be accomplished by a **forward declaration** of the form  `class A;`\n- However, if we also want to access data or function members of A, the compiler needs further info.\n- There are three possibilities:\n  1. Put the complete definition of A into a header file `A.hpp` and include that into the source file `B.cpp`\n  1. Split up the declaration of the member functions and their implementation into two parts. A file `A.hpp` with the class declaration and a file `A.cpp` with the implementation of the member functions.\n  1. Use a combination of both, e.g. to allow inlining of certain short methods.\n- Each of the approaches has pros and cons. So the decision depends on the concrete scenario.\n***\nBrief example on the splitting approach:","metadata":{},"id":"56fb8027-e846-451f-bcda-c28c6e805530"},{"cell_type":"code","source":"%%file splitA.hpp\n\n#include <string>\n\nclass A {\n\n  std::string name_;\n\n  public:\n  void setName( const char* name );\n  void printName();\n\n};","metadata":{"trusted":true},"execution_count":4,"outputs":[{"name":"stdout","text":"Writing splitA.hpp\n","output_type":"stream"}],"id":"867de208-5492-44c0-bf04-7ac9f868908f"},{"cell_type":"code","source":"%%file splitA.cpp\n\n// Necessary, because otherwise compiler does not know a class A and a member function setName exists\n#include \"splitA.hpp\"\n\n// Need to prefix the member function name with the class name\nvoid A::setName( const char* name ) {\n  name_ = name;\n}","metadata":{"trusted":true},"execution_count":5,"outputs":[{"name":"stdout","text":"Writing splitA.cpp\n","output_type":"stream"}],"id":"639efb26-6150-4cdf-aef4-b962ba86a6a3"},{"cell_type":"code","source":"%%file splitB.cpp\n\n#include \"splitA.hpp\"\n\nint main( void ) {\n\n  A obj;\n  obj.setName( \"An object\" );\n\n  // Note: We have not implemented A::printName();\n  //       However, if it is not used, that's not an issue.\n  // obj.printName();\n}","metadata":{"trusted":true},"execution_count":6,"outputs":[{"name":"stdout","text":"Writing splitB.cpp\n","output_type":"stream"}],"id":"3ed47b3b-3b45-4fc3-ab31-655915b41251"},{"cell_type":"code","source":"!g++ splitA.cpp splitB.cpp\n./a.out","metadata":{"trusted":true},"execution_count":7,"outputs":[],"id":"2c897fb0-b3a2-4617-8b92-79dbaaff6b8b"},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[],"id":"782da53e-ca04-42d3-a318-a1501b17b654"}]}
\ No newline at end of file
+{"metadata":{"orig_nbformat":4,"language_info":{"codemirror_mode":"text/x-c++src","file_extension":".cpp","mimetype":"text/x-c++src","name":"c++","version":"17"},"kernelspec":{"name":"xcpp17","display_name":"C++17","language":"C++17"}},"nbformat_minor":5,"nbformat":4,"cells":[{"cell_type":"markdown","source":"## Classes and Objects\n\nLet's try to implement our first class","metadata":{},"id":"e0e9c863-8720-40a4-a22c-00af773497fe"},{"cell_type":"code","source":"class aggregate {\n    short s = 4;\n    unsigned int i = 1u<<16;\n    double x = 2.0;\n};","metadata":{"trusted":true},"execution_count":1,"outputs":[],"id":"bc685489-cf28-4a15-b0ee-fef2e6143f28"},{"cell_type":"code","source":"#include <iostream>\n\nint main() {\n    aggregate agg;\n    std::cout << \"s = \" << agg.s << std::endl;\n    std::cout << \"i = \" << agg.i << std::endl;\n}","metadata":{"trusted":true},"execution_count":2,"outputs":[{"name":"stderr","text":"input_line_9:3:32: error: 's' is a private member of '__cling_N52::aggregate'\n    std::cout << \"s = \" << agg.s << std::endl;\n                               ^\ninput_line_7:2:11: note: implicitly declared private here\n    short s = 4;\n          ^\ninput_line_9:4:32: error: 'i' is a private member of '__cling_N52::aggregate'\n    std::cout << \"i = \" << agg.i << std::endl;\n                               ^\ninput_line_7:3:18: note: implicitly declared private here\n    unsigned int i = 1u<<16;\n                 ^\n","output_type":"stream"},{"ename":"Interpreter Error","evalue":"","traceback":["Interpreter Error: "],"output_type":"error"}],"id":"4ada47eb-7158-4caf-aa60-0eb8df7e4769"},{"cell_type":"markdown","source":"That did not work. Why?","metadata":{},"id":"4035a6b6-f751-44fa-a579-a1166df4eed7"},{"cell_type":"markdown","source":"Because object-oriented programming is also about **encapsulation**. By making certain attributes (data members) and method (member functions) invisible to the outside, we\n  - can enhance safety: better control over the state of an object\n  - make sure that the internal implementation of the class can be changed without breaking outside code  \n\nIn C++ we have three levels of access:\n  - **public** = any one has access \n  - **private** = only the class itself has access\n  - **protected** = the class and its children have access\n  \nThe difference between a struct and a class lies in their default setting\n\n|            | class | struct |\n|:----------:|:-----:|:------:|\n| default is:|private| public |","metadata":{},"id":"159ef323-6f0a-49af-ac06-98804334e5d1"},{"cell_type":"code","source":"class aggregate {\n  \n  double x;         // private by default\n    \npublic:\n    \n  short s = 4;\n  unsigned int i = 1u<<16;\n\n};\n\nstruct combo {\n  \n  int a;            // public by default\n    \nprivate:\n  int internal;     // not accessible from outside\n\n};","metadata":{"trusted":true},"execution_count":3,"outputs":[],"id":"7ea6dfba-43fe-4730-b845-4bd49c9b3e3a"},{"cell_type":"code","source":"#include <iostream>\n\nint main() {\n  aggregate agg;\n  std::cout << \"s = \" << agg.s << std::endl;\n  std::cout << \"i = \" << agg.i << std::endl;\n\n  combo s;\n  s.a = 7;\n}\n\nmain();","metadata":{"trusted":true},"execution_count":4,"outputs":[{"name":"stderr","text":"In file included from input_line_1:1:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/new:40:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/exception:144:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/nested_exception.h:40:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/move.h:55:\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/type_traits:137:31: error: no member named 'value' in 'std::__not_<std::is_lvalue_reference<std::basic_ostream<char> &> >'\n    : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type\n                         ~~~~~^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:685:24: note: in instantiation of template class 'std::__and_<std::__not_<std::is_lvalue_reference<std::basic_ostream<char> &> >, std::__is_convertible_to_basic_ostream<std::basic_ostream<char> &>, std::__is_insertable<std::basic_ostream<char> &, char const (&)[5], void> >' requested here\n    typename enable_if<__and_<__not_<is_lvalue_reference<_Ostream>>,\n                       ^\ninput_line_12:3:13: note: while substituting deduced template arguments into function template 'operator<<' [with _Ostream = std::basic_ostream<char> &, _Tp = char [5]]\n  std::cout << \"s = \" << agg.s << std::endl;\n            ^\nIn file included from input_line_1:1:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/new:40:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/exception:144:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/nested_exception.h:40:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/move.h:55:\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/type_traits:137:31: error: no member named 'value' in 'std::__not_<std::is_lvalue_reference<std::basic_ostream<char> &> >'\n    : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type\n                         ~~~~~^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:685:24: note: in instantiation of template class 'std::__and_<std::__not_<std::is_lvalue_reference<std::basic_ostream<char> &> >, std::__is_convertible_to_basic_ostream<std::basic_ostream<char> &>, std::__is_insertable<std::basic_ostream<char> &, const short &, void> >' requested here\n    typename enable_if<__and_<__not_<is_lvalue_reference<_Ostream>>,\n                       ^\ninput_line_12:3:23: note: while substituting deduced template arguments into function template 'operator<<' [with _Ostream = std::basic_ostream<char> &, _Tp = short]\n  std::cout << \"s = \" << agg.s << std::endl;\n                      ^\ninput_line_12:3:35: error: reference to overloaded function could not be resolved; did you mean to call it?\n  std::cout << \"s = \" << agg.s << std::endl;\n                                  ^~~~~~~~~\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:599:5: note: possible target for call\n    endl(basic_ostream<_CharT, _Traits>& __os)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:245:7: note: candidate function not viable: no overload of 'endl' matching 'const void *' for 1st argument\n      operator<<(const void* __p)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/string_view:580:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'basic_string_view<char, std::char_traits<char> >' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/system_error:217:5: note: candidate function not viable: no overload of 'endl' matching 'const std::error_code' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:117:7: note: candidate function not viable: no overload of 'endl' matching 'std::basic_ostream<char, std::char_traits<char> >::__ios_type &(*)(std::basic_ostream<char, std::char_traits<char> >::__ios_type &)' (aka 'basic_ios<char, std::char_traits<char> > &(*)(basic_ios<char, std::char_traits<char> > &)') for 1st argument\n      operator<<(__ios_type& (*__pf)(__ios_type&))\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:127:7: note: candidate function not viable: no overload of 'endl' matching 'std::ios_base &(*)(std::ios_base &)' for 1st argument\n      operator<<(ios_base& (*__pf) (ios_base&))\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:166:7: note: candidate function not viable: no overload of 'endl' matching 'long' for 1st argument\n      operator<<(long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:170:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned long' for 1st argument\n      operator<<(unsigned long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:174:7: note: candidate function not viable: no overload of 'endl' matching 'bool' for 1st argument\n      operator<<(bool __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:178:7: note: candidate function not viable: no overload of 'endl' matching 'short' for 1st argument\n      operator<<(short __n);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:181:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned short' for 1st argument\n      operator<<(unsigned short __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:189:7: note: candidate function not viable: no overload of 'endl' matching 'int' for 1st argument\n      operator<<(int __n);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:201:7: note: candidate function not viable: no overload of 'endl' matching 'long long' for 1st argument\n      operator<<(long long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:205:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned long long' for 1st argument\n      operator<<(unsigned long long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:220:7: note: candidate function not viable: no overload of 'endl' matching 'double' for 1st argument\n      operator<<(double __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:224:7: note: candidate function not viable: no overload of 'endl' matching 'float' for 1st argument\n      operator<<(float __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:232:7: note: candidate function not viable: no overload of 'endl' matching 'long double' for 1st argument\n      operator<<(long double __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:250:7: note: candidate function not viable: no overload of 'endl' matching 'std::nullptr_t' (aka 'nullptr_t') for 1st argument\n      operator<<(nullptr_t)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:276:7: note: candidate function not viable: no overload of 'endl' matching 'std::basic_ostream<char, std::char_traits<char> >::__streambuf_type *' (aka 'basic_streambuf<char, std::char_traits<char> > *') for 1st argument\n      operator<<(__streambuf_type* __sb);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:506:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:511:5: note: candidate function not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:517:5: note: candidate function not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:523:5: note: candidate function not viable: no overload of 'endl' matching 'signed char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, signed char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:528:5: note: candidate function not viable: no overload of 'endl' matching 'unsigned char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:548:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:565:5: note: candidate function not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:578:5: note: candidate function not viable: no overload of 'endl' matching 'const signed char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:583:5: note: candidate function not viable: no overload of 'endl' matching 'const unsigned char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/ostream.tcc:321:5: note: candidate function not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/basic_string.h:6419:5: note: candidate template ignored: couldn't infer template argument '_Alloc'\n    operator<<(basic_ostream<_CharT, _Traits>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/cstddef:130:5: note: candidate template ignored: couldn't infer template argument '_IntegerType'\n    operator<<(byte __b, _IntegerType __shift) noexcept\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:691:5: note: candidate template ignored: couldn't infer template argument '_Tp'\n    operator<<(_Ostream&& __os, const _Tp& __x)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/shared_ptr.h:66:5: note: candidate template ignored: couldn't infer template argument '_Tp'\n    operator<<(std::basic_ostream<_Ch, _Tr>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: couldn't infer template argument '_Dom'\n    _DEFINE_EXPR_BINARY_OPERATOR(<<, __shift_left)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:370:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const typename _Dom::value_type& __t,                  \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: couldn't infer template argument '_Dom'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:396:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const valarray<typename _Dom::value_type>& __v,        \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: couldn't infer template argument '_Tp'\n_DEFINE_BINARY_OPERATOR(<<, __shift_left)\n^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1177:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const typename valarray<_Tp>::value_type& __t,         \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n    _DEFINE_EXPR_BINARY_OPERATOR(<<, __shift_left)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:344:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom1, typename _Dom1::value_type>& __v,   \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:357:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom, typename _Dom::value_type>& __v,     \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:383:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom,typename _Dom::value_type>& __e,      \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: could not match 'valarray' against 'basic_ostream'\n_DEFINE_BINARY_OPERATOR(<<, __shift_left)\n^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1155:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const valarray<_Tp>& __v, const valarray<_Tp>& __w)    \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: could not match 'valarray' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1166:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const valarray<_Tp>& __v,                              \\\n    ^\nIn file included from input_line_1:1:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/new:40:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/exception:144:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/nested_exception.h:40:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/move.h:55:\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/type_traits:137:31: error: no member named 'value' in 'std::__not_<std::is_lvalue_reference<std::basic_ostream<char> &> >'\n    : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type\n                         ~~~~~^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:685:24: note: in instantiation of template class 'std::__and_<std::__not_<std::is_lvalue_reference<std::basic_ostream<char> &> >, std::__is_convertible_to_basic_ostream<std::basic_ostream<char> &>, std::__is_insertable<std::basic_ostream<char> &, const unsigned int &, void> >' requested here\n    typename enable_if<__and_<__not_<is_lvalue_reference<_Ostream>>,\n                       ^\ninput_line_12:4:23: note: while substituting deduced template arguments into function template 'operator<<' [with _Ostream = std::basic_ostream<char> &, _Tp = unsigned int]\n  std::cout << \"i = \" << agg.i << std::endl;\n                      ^\ninput_line_12:4:23: error: use of overloaded operator '<<' is ambiguous (with operand types 'basic_ostream<char, std::char_traits<char> >' and 'unsigned int')\n  std::cout << \"i = \" << agg.i << std::endl;\n  ~~~~~~~~~~~~~~~~~~~ ^  ~~~~~\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:166:7: note: candidate function\n      operator<<(long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:170:7: note: candidate function\n      operator<<(unsigned long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:174:7: note: candidate function\n      operator<<(bool __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:178:7: note: candidate function\n      operator<<(short __n);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:181:7: note: candidate function\n      operator<<(unsigned short __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:189:7: note: candidate function\n      operator<<(int __n);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:201:7: note: candidate function\n      operator<<(long long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:205:7: note: candidate function\n      operator<<(unsigned long long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:220:7: note: candidate function\n      operator<<(double __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:224:7: note: candidate function\n      operator<<(float __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:232:7: note: candidate function\n      operator<<(long double __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:517:5: note: candidate function [with _Traits = std::char_traits<char>]\n    operator<<(basic_ostream<char, _Traits>& __out, char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:511:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>]\n    operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:523:5: note: candidate function [with _Traits = std::char_traits<char>]\n    operator<<(basic_ostream<char, _Traits>& __out, signed char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:528:5: note: candidate function [with _Traits = std::char_traits<char>]\n    operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:568:8: error: no member named 'setstate' in 'std::basic_ostream<char>'\n        __out.setstate(ios_base::badbit);\n        ~~~~~ ^\ninput_line_12:3:13: note: in instantiation of function template specialization 'std::operator<<<std::char_traits<char> >' requested here\n  std::cout << \"s = \" << agg.s << std::endl;\n            ^\n","output_type":"stream"},{"ename":"Interpreter Error","evalue":"","traceback":["Interpreter Error: "],"output_type":"error"}],"id":"6b4cd5c9-0ec3-451b-95b3-e9ad857eea83"},{"cell_type":"markdown","source":"An **object** is an instance of a class; different objects are different entities.","metadata":{},"id":"8c9241eb-1530-42db-8f50-542b8b74bbb8"},{"cell_type":"code","source":"int main() {\n    \n    aggregate a, b, c;\n    \n    a.s = 1;\n    b.s = 2;\n    c.s = 3;\n    \n    std::cout << \"a's short has a value of \" << a.s << '\\n'\n              << \"b's short has a value of \" << b.s << '\\n'\n              << \"c's short has a value of \" << c.s << std::endl;\n    \n    a = c;\n    std::cout << \"now a.s = \" << a.s << std::endl;\n}","metadata":{"trusted":true},"execution_count":5,"outputs":[{"name":"stderr","text":"In file included from input_line_1:1:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/new:40:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/exception:144:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/nested_exception.h:40:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/move.h:55:\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/type_traits:137:31: error: no member named 'value' in 'std::__not_<std::is_lvalue_reference<std::basic_ostream<char> &> >'\n    : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type\n                         ~~~~~^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:685:24: note: in instantiation of template class 'std::__and_<std::__not_<std::is_lvalue_reference<std::basic_ostream<char> &> >, std::__is_convertible_to_basic_ostream<std::basic_ostream<char> &>, std::__is_insertable<std::basic_ostream<char> &, char const (&)[26], void> >' requested here\n    typename enable_if<__and_<__not_<is_lvalue_reference<_Ostream>>,\n                       ^\ninput_line_13:9:15: note: while substituting deduced template arguments into function template 'operator<<' [with _Ostream = std::basic_ostream<char> &, _Tp = char [26]]\n    std::cout << \"a's short has a value of \" << a.s << '\\n'\n              ^\nIn file included from input_line_1:1:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/new:40:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/exception:144:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/nested_exception.h:40:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/move.h:55:\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/type_traits:137:31: error: no member named 'value' in 'std::__not_<std::is_lvalue_reference<std::basic_ostream<char> &> >'\n    : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type\n                         ~~~~~^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:685:24: note: in instantiation of template class 'std::__and_<std::__not_<std::is_lvalue_reference<std::basic_ostream<char> &> >, std::__is_convertible_to_basic_ostream<std::basic_ostream<char> &>, std::__is_insertable<std::basic_ostream<char> &, const char &, void> >' requested here\n    typename enable_if<__and_<__not_<is_lvalue_reference<_Ostream>>,\n                       ^\ninput_line_13:9:53: note: while substituting deduced template arguments into function template 'operator<<' [with _Ostream = std::basic_ostream<char> &, _Tp = char]\n    std::cout << \"a's short has a value of \" << a.s << '\\n'\n                                                    ^\ninput_line_13:11:56: error: reference to overloaded function could not be resolved; did you mean to call it?\n              << \"c's short has a value of \" << c.s << std::endl;\n                                                       ^~~~~~~~~\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:599:5: note: possible target for call\n    endl(basic_ostream<_CharT, _Traits>& __os)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:245:7: note: candidate function not viable: no overload of 'endl' matching 'const void *' for 1st argument\n      operator<<(const void* __p)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/string_view:580:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'basic_string_view<char, std::char_traits<char> >' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/system_error:217:5: note: candidate function not viable: no overload of 'endl' matching 'const std::error_code' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:117:7: note: candidate function not viable: no overload of 'endl' matching 'std::basic_ostream<char, std::char_traits<char> >::__ios_type &(*)(std::basic_ostream<char, std::char_traits<char> >::__ios_type &)' (aka 'basic_ios<char, std::char_traits<char> > &(*)(basic_ios<char, std::char_traits<char> > &)') for 1st argument\n      operator<<(__ios_type& (*__pf)(__ios_type&))\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:127:7: note: candidate function not viable: no overload of 'endl' matching 'std::ios_base &(*)(std::ios_base &)' for 1st argument\n      operator<<(ios_base& (*__pf) (ios_base&))\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:166:7: note: candidate function not viable: no overload of 'endl' matching 'long' for 1st argument\n      operator<<(long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:170:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned long' for 1st argument\n      operator<<(unsigned long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:174:7: note: candidate function not viable: no overload of 'endl' matching 'bool' for 1st argument\n      operator<<(bool __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:178:7: note: candidate function not viable: no overload of 'endl' matching 'short' for 1st argument\n      operator<<(short __n);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:181:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned short' for 1st argument\n      operator<<(unsigned short __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:189:7: note: candidate function not viable: no overload of 'endl' matching 'int' for 1st argument\n      operator<<(int __n);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:201:7: note: candidate function not viable: no overload of 'endl' matching 'long long' for 1st argument\n      operator<<(long long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:205:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned long long' for 1st argument\n      operator<<(unsigned long long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:220:7: note: candidate function not viable: no overload of 'endl' matching 'double' for 1st argument\n      operator<<(double __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:224:7: note: candidate function not viable: no overload of 'endl' matching 'float' for 1st argument\n      operator<<(float __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:232:7: note: candidate function not viable: no overload of 'endl' matching 'long double' for 1st argument\n      operator<<(long double __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:250:7: note: candidate function not viable: no overload of 'endl' matching 'std::nullptr_t' (aka 'nullptr_t') for 1st argument\n      operator<<(nullptr_t)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:276:7: note: candidate function not viable: no overload of 'endl' matching 'std::basic_ostream<char, std::char_traits<char> >::__streambuf_type *' (aka 'basic_streambuf<char, std::char_traits<char> > *') for 1st argument\n      operator<<(__streambuf_type* __sb);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:506:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:511:5: note: candidate function not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:517:5: note: candidate function not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:523:5: note: candidate function not viable: no overload of 'endl' matching 'signed char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, signed char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:528:5: note: candidate function not viable: no overload of 'endl' matching 'unsigned char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:548:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:565:5: note: candidate function not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:578:5: note: candidate function not viable: no overload of 'endl' matching 'const signed char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:583:5: note: candidate function not viable: no overload of 'endl' matching 'const unsigned char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/ostream.tcc:321:5: note: candidate function not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/basic_string.h:6419:5: note: candidate template ignored: couldn't infer template argument '_Alloc'\n    operator<<(basic_ostream<_CharT, _Traits>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/cstddef:130:5: note: candidate template ignored: couldn't infer template argument '_IntegerType'\n    operator<<(byte __b, _IntegerType __shift) noexcept\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:691:5: note: candidate template ignored: couldn't infer template argument '_Tp'\n    operator<<(_Ostream&& __os, const _Tp& __x)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/shared_ptr.h:66:5: note: candidate template ignored: couldn't infer template argument '_Tp'\n    operator<<(std::basic_ostream<_Ch, _Tr>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: couldn't infer template argument '_Dom'\n    _DEFINE_EXPR_BINARY_OPERATOR(<<, __shift_left)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:370:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const typename _Dom::value_type& __t,                  \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: couldn't infer template argument '_Dom'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:396:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const valarray<typename _Dom::value_type>& __v,        \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: couldn't infer template argument '_Tp'\n_DEFINE_BINARY_OPERATOR(<<, __shift_left)\n^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1177:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const typename valarray<_Tp>::value_type& __t,         \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n    _DEFINE_EXPR_BINARY_OPERATOR(<<, __shift_left)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:344:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom1, typename _Dom1::value_type>& __v,   \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:357:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom, typename _Dom::value_type>& __v,     \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:383:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom,typename _Dom::value_type>& __e,      \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: could not match 'valarray' against 'basic_ostream'\n_DEFINE_BINARY_OPERATOR(<<, __shift_left)\n^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1155:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const valarray<_Tp>& __v, const valarray<_Tp>& __w)    \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: could not match 'valarray' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1166:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const valarray<_Tp>& __v,                              \\\n    ^\nIn file included from input_line_1:1:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/new:40:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/exception:144:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/nested_exception.h:40:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/move.h:55:\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/type_traits:137:31: error: no member named 'value' in 'std::__not_<std::is_lvalue_reference<std::basic_ostream<char> &> >'\n    : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type\n                         ~~~~~^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:685:24: note: in instantiation of template class 'std::__and_<std::__not_<std::is_lvalue_reference<std::basic_ostream<char> &> >, std::__is_convertible_to_basic_ostream<std::basic_ostream<char> &>, std::__is_insertable<std::basic_ostream<char> &, char const (&)[11], void> >' requested here\n    typename enable_if<__and_<__not_<is_lvalue_reference<_Ostream>>,\n                       ^\ninput_line_13:14:15: note: while substituting deduced template arguments into function template 'operator<<' [with _Ostream = std::basic_ostream<char> &, _Tp = char [11]]\n    std::cout << \"now a.s = \" << a.s << std::endl;\n              ^\ninput_line_13:14:41: error: reference to overloaded function could not be resolved; did you mean to call it?\n    std::cout << \"now a.s = \" << a.s << std::endl;\n                                        ^~~~~~~~~\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:599:5: note: possible target for call\n    endl(basic_ostream<_CharT, _Traits>& __os)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:245:7: note: candidate function not viable: no overload of 'endl' matching 'const void *' for 1st argument\n      operator<<(const void* __p)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/string_view:580:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'basic_string_view<char, std::char_traits<char> >' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/system_error:217:5: note: candidate function not viable: no overload of 'endl' matching 'const std::error_code' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:117:7: note: candidate function not viable: no overload of 'endl' matching 'std::basic_ostream<char, std::char_traits<char> >::__ios_type &(*)(std::basic_ostream<char, std::char_traits<char> >::__ios_type &)' (aka 'basic_ios<char, std::char_traits<char> > &(*)(basic_ios<char, std::char_traits<char> > &)') for 1st argument\n      operator<<(__ios_type& (*__pf)(__ios_type&))\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:127:7: note: candidate function not viable: no overload of 'endl' matching 'std::ios_base &(*)(std::ios_base &)' for 1st argument\n      operator<<(ios_base& (*__pf) (ios_base&))\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:166:7: note: candidate function not viable: no overload of 'endl' matching 'long' for 1st argument\n      operator<<(long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:170:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned long' for 1st argument\n      operator<<(unsigned long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:174:7: note: candidate function not viable: no overload of 'endl' matching 'bool' for 1st argument\n      operator<<(bool __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:178:7: note: candidate function not viable: no overload of 'endl' matching 'short' for 1st argument\n      operator<<(short __n);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:181:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned short' for 1st argument\n      operator<<(unsigned short __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:189:7: note: candidate function not viable: no overload of 'endl' matching 'int' for 1st argument\n      operator<<(int __n);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:201:7: note: candidate function not viable: no overload of 'endl' matching 'long long' for 1st argument\n      operator<<(long long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:205:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned long long' for 1st argument\n      operator<<(unsigned long long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:220:7: note: candidate function not viable: no overload of 'endl' matching 'double' for 1st argument\n      operator<<(double __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:224:7: note: candidate function not viable: no overload of 'endl' matching 'float' for 1st argument\n      operator<<(float __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:232:7: note: candidate function not viable: no overload of 'endl' matching 'long double' for 1st argument\n      operator<<(long double __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:250:7: note: candidate function not viable: no overload of 'endl' matching 'std::nullptr_t' (aka 'nullptr_t') for 1st argument\n      operator<<(nullptr_t)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:276:7: note: candidate function not viable: no overload of 'endl' matching 'std::basic_ostream<char, std::char_traits<char> >::__streambuf_type *' (aka 'basic_streambuf<char, std::char_traits<char> > *') for 1st argument\n      operator<<(__streambuf_type* __sb);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:506:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:511:5: note: candidate function not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:517:5: note: candidate function not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:523:5: note: candidate function not viable: no overload of 'endl' matching 'signed char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, signed char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:528:5: note: candidate function not viable: no overload of 'endl' matching 'unsigned char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:548:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:565:5: note: candidate function not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:578:5: note: candidate function not viable: no overload of 'endl' matching 'const signed char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:583:5: note: candidate function not viable: no overload of 'endl' matching 'const unsigned char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/ostream.tcc:321:5: note: candidate function not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/basic_string.h:6419:5: note: candidate template ignored: couldn't infer template argument '_Alloc'\n    operator<<(basic_ostream<_CharT, _Traits>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/cstddef:130:5: note: candidate template ignored: couldn't infer template argument '_IntegerType'\n    operator<<(byte __b, _IntegerType __shift) noexcept\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:691:5: note: candidate template ignored: couldn't infer template argument '_Tp'\n    operator<<(_Ostream&& __os, const _Tp& __x)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/shared_ptr.h:66:5: note: candidate template ignored: couldn't infer template argument '_Tp'\n    operator<<(std::basic_ostream<_Ch, _Tr>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: couldn't infer template argument '_Dom'\n    _DEFINE_EXPR_BINARY_OPERATOR(<<, __shift_left)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:370:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const typename _Dom::value_type& __t,                  \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: couldn't infer template argument '_Dom'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:396:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const valarray<typename _Dom::value_type>& __v,        \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: couldn't infer template argument '_Tp'\n_DEFINE_BINARY_OPERATOR(<<, __shift_left)\n^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1177:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const typename valarray<_Tp>::value_type& __t,         \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n    _DEFINE_EXPR_BINARY_OPERATOR(<<, __shift_left)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:344:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom1, typename _Dom1::value_type>& __v,   \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:357:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom, typename _Dom::value_type>& __v,     \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:383:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom,typename _Dom::value_type>& __e,      \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: could not match 'valarray' against 'basic_ostream'\n_DEFINE_BINARY_OPERATOR(<<, __shift_left)\n^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1155:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const valarray<_Tp>& __v, const valarray<_Tp>& __w)    \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: could not match 'valarray' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1166:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const valarray<_Tp>& __v,                              \\\n    ^\nIn file included from input_line_5:1:\nIn file included from /srv/conda/envs/notebook/include/xeus/xinterpreter.hpp:17:\nIn file included from /srv/conda/envs/notebook/include/xeus/xcomm.hpp:19:\nIn file included from /srv/conda/envs/notebook/include/nlohmann/json.hpp:42:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/iterator:64:\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:568:8: error: no member named 'setstate' in 'std::basic_ostream<char>'\n        __out.setstate(ios_base::badbit);\n        ~~~~~ ^\ninput_line_13:9:15: note: in instantiation of function template specialization 'std::operator<<<std::char_traits<char> >' requested here\n    std::cout << \"a's short has a value of \" << a.s << '\\n'\n              ^\n","output_type":"stream"},{"ename":"Interpreter Error","evalue":"","traceback":["Interpreter Error: "],"output_type":"error"}],"id":"2f93bb55-528a-4bac-8336-ccf98cc18af0"},{"cell_type":"code","source":"main();","metadata":{"trusted":true},"execution_count":null,"outputs":[],"id":"e5ca8f44-4f3f-4142-8b5e-f5a3c31fee7e"},{"cell_type":"markdown","source":"### Constructors\n\n- Our class *aggregate* used *default member initializers* for setting initial values for its data members.\n- This is one possibility. The other is to use a *constructor* and a *member initializer list*.\n- Constructors are also required, if we want to run some start-up code as part of object creation.","metadata":{},"id":"fe29c0f5-6967-403d-b796-779fe1ccf4be"},{"cell_type":"code","source":"#include <iostream>\n\nclass myClass{\n    \n    public:\n        myClass() : memb_(0) {\n            std::cout << \"An instance of myClass was generated.\"\n                      << \" memb_ = \" << memb_ << std::endl;\n        }\n    \n    private:\n        int memb_;    // some people adhere to the convention of marking data members by a trailing \"_\"\n}","metadata":{"trusted":true},"execution_count":6,"outputs":[{"name":"stderr","text":"In file included from input_line_1:1:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/new:40:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/exception:144:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/nested_exception.h:40:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/move.h:55:\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/type_traits:137:31: error: no member named 'value' in 'std::__not_<std::is_lvalue_reference<std::basic_ostream<char> &> >'\n    : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type\n                         ~~~~~^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:685:24: note: in instantiation of template class 'std::__and_<std::__not_<std::is_lvalue_reference<std::basic_ostream<char> &> >, std::__is_convertible_to_basic_ostream<std::basic_ostream<char> &>, std::__is_insertable<std::basic_ostream<char> &, char const (&)[38], void> >' requested here\n    typename enable_if<__and_<__not_<is_lvalue_reference<_Ostream>>,\n                       ^\ninput_line_15:5:23: note: while substituting deduced template arguments into function template 'operator<<' [with _Ostream = std::basic_ostream<char> &, _Tp = char [38]]\n            std::cout << \"An instance of myClass was generated.\"\n                      ^\nIn file included from input_line_1:1:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/new:40:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/exception:144:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/nested_exception.h:40:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/move.h:55:\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/type_traits:137:31: error: no member named 'value' in 'std::__not_<std::is_lvalue_reference<std::basic_ostream<char> &> >'\n    : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type\n                         ~~~~~^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:685:24: note: in instantiation of template class 'std::__and_<std::__not_<std::is_lvalue_reference<std::basic_ostream<char> &> >, std::__is_convertible_to_basic_ostream<std::basic_ostream<char> &>, std::__is_insertable<std::basic_ostream<char> &, char const (&)[10], void> >' requested here\n    typename enable_if<__and_<__not_<is_lvalue_reference<_Ostream>>,\n                       ^\ninput_line_15:6:23: note: while substituting deduced template arguments into function template 'operator<<' [with _Ostream = std::basic_ostream<char> &, _Tp = char [10]]\n                      << \" memb_ = \" << memb_ << std::endl;\n                      ^\nIn file included from input_line_1:1:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/new:40:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/exception:144:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/nested_exception.h:40:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/move.h:55:\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/type_traits:137:31: error: no member named 'value' in 'std::__not_<std::is_lvalue_reference<std::basic_ostream<char> &> >'\n    : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type\n                         ~~~~~^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:685:24: note: in instantiation of template class 'std::__and_<std::__not_<std::is_lvalue_reference<std::basic_ostream<char> &> >, std::__is_convertible_to_basic_ostream<std::basic_ostream<char> &>, std::__is_insertable<std::basic_ostream<char> &, const int &, void> >' requested here\n    typename enable_if<__and_<__not_<is_lvalue_reference<_Ostream>>,\n                       ^\ninput_line_15:6:38: note: while substituting deduced template arguments into function template 'operator<<' [with _Ostream = std::basic_ostream<char> &, _Tp = int]\n                      << \" memb_ = \" << memb_ << std::endl;\n                                     ^\ninput_line_15:6:50: error: reference to overloaded function could not be resolved; did you mean to call it?\n                      << \" memb_ = \" << memb_ << std::endl;\n                                                 ^~~~~~~~~\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:599:5: note: possible target for call\n    endl(basic_ostream<_CharT, _Traits>& __os)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:245:7: note: candidate function not viable: no overload of 'endl' matching 'const void *' for 1st argument\n      operator<<(const void* __p)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/string_view:580:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'basic_string_view<char, std::char_traits<char> >' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/system_error:217:5: note: candidate function not viable: no overload of 'endl' matching 'const std::error_code' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:117:7: note: candidate function not viable: no overload of 'endl' matching 'std::basic_ostream<char, std::char_traits<char> >::__ios_type &(*)(std::basic_ostream<char, std::char_traits<char> >::__ios_type &)' (aka 'basic_ios<char, std::char_traits<char> > &(*)(basic_ios<char, std::char_traits<char> > &)') for 1st argument\n      operator<<(__ios_type& (*__pf)(__ios_type&))\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:127:7: note: candidate function not viable: no overload of 'endl' matching 'std::ios_base &(*)(std::ios_base &)' for 1st argument\n      operator<<(ios_base& (*__pf) (ios_base&))\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:166:7: note: candidate function not viable: no overload of 'endl' matching 'long' for 1st argument\n      operator<<(long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:170:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned long' for 1st argument\n      operator<<(unsigned long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:174:7: note: candidate function not viable: no overload of 'endl' matching 'bool' for 1st argument\n      operator<<(bool __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:178:7: note: candidate function not viable: no overload of 'endl' matching 'short' for 1st argument\n      operator<<(short __n);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:181:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned short' for 1st argument\n      operator<<(unsigned short __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:189:7: note: candidate function not viable: no overload of 'endl' matching 'int' for 1st argument\n      operator<<(int __n);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:201:7: note: candidate function not viable: no overload of 'endl' matching 'long long' for 1st argument\n      operator<<(long long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:205:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned long long' for 1st argument\n      operator<<(unsigned long long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:220:7: note: candidate function not viable: no overload of 'endl' matching 'double' for 1st argument\n      operator<<(double __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:224:7: note: candidate function not viable: no overload of 'endl' matching 'float' for 1st argument\n      operator<<(float __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:232:7: note: candidate function not viable: no overload of 'endl' matching 'long double' for 1st argument\n      operator<<(long double __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:250:7: note: candidate function not viable: no overload of 'endl' matching 'std::nullptr_t' (aka 'nullptr_t') for 1st argument\n      operator<<(nullptr_t)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:276:7: note: candidate function not viable: no overload of 'endl' matching 'std::basic_ostream<char, std::char_traits<char> >::__streambuf_type *' (aka 'basic_streambuf<char, std::char_traits<char> > *') for 1st argument\n      operator<<(__streambuf_type* __sb);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:506:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:511:5: note: candidate function not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:517:5: note: candidate function not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:523:5: note: candidate function not viable: no overload of 'endl' matching 'signed char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, signed char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:528:5: note: candidate function not viable: no overload of 'endl' matching 'unsigned char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:548:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:565:5: note: candidate function not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:578:5: note: candidate function not viable: no overload of 'endl' matching 'const signed char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:583:5: note: candidate function not viable: no overload of 'endl' matching 'const unsigned char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/ostream.tcc:321:5: note: candidate function not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/basic_string.h:6419:5: note: candidate template ignored: couldn't infer template argument '_Alloc'\n    operator<<(basic_ostream<_CharT, _Traits>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/cstddef:130:5: note: candidate template ignored: couldn't infer template argument '_IntegerType'\n    operator<<(byte __b, _IntegerType __shift) noexcept\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:691:5: note: candidate template ignored: couldn't infer template argument '_Tp'\n    operator<<(_Ostream&& __os, const _Tp& __x)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/shared_ptr.h:66:5: note: candidate template ignored: couldn't infer template argument '_Tp'\n    operator<<(std::basic_ostream<_Ch, _Tr>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: couldn't infer template argument '_Dom'\n    _DEFINE_EXPR_BINARY_OPERATOR(<<, __shift_left)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:370:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const typename _Dom::value_type& __t,                  \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: couldn't infer template argument '_Dom'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:396:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const valarray<typename _Dom::value_type>& __v,        \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: couldn't infer template argument '_Tp'\n_DEFINE_BINARY_OPERATOR(<<, __shift_left)\n^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1177:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const typename valarray<_Tp>::value_type& __t,         \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n    _DEFINE_EXPR_BINARY_OPERATOR(<<, __shift_left)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:344:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom1, typename _Dom1::value_type>& __v,   \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:357:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom, typename _Dom::value_type>& __v,     \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:383:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom,typename _Dom::value_type>& __e,      \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: could not match 'valarray' against 'basic_ostream'\n_DEFINE_BINARY_OPERATOR(<<, __shift_left)\n^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1155:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const valarray<_Tp>& __v, const valarray<_Tp>& __w)    \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: could not match 'valarray' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1166:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const valarray<_Tp>& __v,                              \\\n    ^\nIn file included from input_line_5:1:\nIn file included from /srv/conda/envs/notebook/include/xeus/xinterpreter.hpp:17:\nIn file included from /srv/conda/envs/notebook/include/xeus/xcomm.hpp:19:\nIn file included from /srv/conda/envs/notebook/include/nlohmann/json.hpp:42:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/iterator:64:\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:568:8: error: no member named 'setstate' in 'std::basic_ostream<char>'\n        __out.setstate(ios_base::badbit);\n        ~~~~~ ^\ninput_line_15:5:23: note: in instantiation of function template specialization 'std::operator<<<std::char_traits<char> >' requested here\n            std::cout << \"An instance of myClass was generated.\"\n                      ^\n","output_type":"stream"},{"ename":"Interpreter Error","evalue":"","traceback":["Interpreter Error: "],"output_type":"error"}],"id":"4c961b3c-ba83-46e6-aab1-08f1ad4102e3"},{"cell_type":"code","source":"int main() {\n    myClass myObj;\n}\n\nmain();","metadata":{"trusted":true},"execution_count":null,"outputs":[],"id":"f501dce2-ef23-4345-8072-45ea85cb8c17"},{"cell_type":"markdown","source":"#### Multiple Constructors\nC++ allows to overload functions. One can use this to implement different constructors.","metadata":{},"id":"5a5ded92-91fc-4a2f-8628-d9531cd84ea2"},{"cell_type":"code","source":"class myClass{\n    \n    public:\n        myClass() : memb_(0) {\n            std::cout << \"An instance of myClass was generated.\"\n                      << \" memb_ = \" << memb_ << std::endl;\n        }\n    \n        myClass( int member ) : memb_(member) {\n            std::cout << \"An instance of myClass was generated.\"\n                      << \" memb_ = \" << memb_ << std::endl;\n        }\n    \n    private:\n        int memb_;\n}","metadata":{"trusted":true},"execution_count":7,"outputs":[{"name":"stderr","text":"input_line_16:6:50: error: reference to overloaded function could not be resolved; did you mean to call it?\n                      << \" memb_ = \" << memb_ << std::endl;\n                                                 ^~~~~~~~~\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:599:5: note: possible target for call\n    endl(basic_ostream<_CharT, _Traits>& __os)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:245:7: note: candidate function not viable: no overload of 'endl' matching 'const void *' for 1st argument\n      operator<<(const void* __p)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/string_view:580:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'basic_string_view<char, std::char_traits<char> >' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/system_error:217:5: note: candidate function not viable: no overload of 'endl' matching 'const std::error_code' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:117:7: note: candidate function not viable: no overload of 'endl' matching 'std::basic_ostream<char, std::char_traits<char> >::__ios_type &(*)(std::basic_ostream<char, std::char_traits<char> >::__ios_type &)' (aka 'basic_ios<char, std::char_traits<char> > &(*)(basic_ios<char, std::char_traits<char> > &)') for 1st argument\n      operator<<(__ios_type& (*__pf)(__ios_type&))\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:127:7: note: candidate function not viable: no overload of 'endl' matching 'std::ios_base &(*)(std::ios_base &)' for 1st argument\n      operator<<(ios_base& (*__pf) (ios_base&))\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:166:7: note: candidate function not viable: no overload of 'endl' matching 'long' for 1st argument\n      operator<<(long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:170:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned long' for 1st argument\n      operator<<(unsigned long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:174:7: note: candidate function not viable: no overload of 'endl' matching 'bool' for 1st argument\n      operator<<(bool __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:178:7: note: candidate function not viable: no overload of 'endl' matching 'short' for 1st argument\n      operator<<(short __n);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:181:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned short' for 1st argument\n      operator<<(unsigned short __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:189:7: note: candidate function not viable: no overload of 'endl' matching 'int' for 1st argument\n      operator<<(int __n);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:201:7: note: candidate function not viable: no overload of 'endl' matching 'long long' for 1st argument\n      operator<<(long long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:205:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned long long' for 1st argument\n      operator<<(unsigned long long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:220:7: note: candidate function not viable: no overload of 'endl' matching 'double' for 1st argument\n      operator<<(double __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:224:7: note: candidate function not viable: no overload of 'endl' matching 'float' for 1st argument\n      operator<<(float __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:232:7: note: candidate function not viable: no overload of 'endl' matching 'long double' for 1st argument\n      operator<<(long double __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:250:7: note: candidate function not viable: no overload of 'endl' matching 'std::nullptr_t' (aka 'nullptr_t') for 1st argument\n      operator<<(nullptr_t)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:276:7: note: candidate function not viable: no overload of 'endl' matching 'std::basic_ostream<char, std::char_traits<char> >::__streambuf_type *' (aka 'basic_streambuf<char, std::char_traits<char> > *') for 1st argument\n      operator<<(__streambuf_type* __sb);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:506:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:511:5: note: candidate function not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:517:5: note: candidate function not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:523:5: note: candidate function not viable: no overload of 'endl' matching 'signed char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, signed char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:528:5: note: candidate function not viable: no overload of 'endl' matching 'unsigned char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:548:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:565:5: note: candidate function not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:578:5: note: candidate function not viable: no overload of 'endl' matching 'const signed char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:583:5: note: candidate function not viable: no overload of 'endl' matching 'const unsigned char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/ostream.tcc:321:5: note: candidate function not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/basic_string.h:6419:5: note: candidate template ignored: couldn't infer template argument '_Alloc'\n    operator<<(basic_ostream<_CharT, _Traits>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/cstddef:130:5: note: candidate template ignored: couldn't infer template argument '_IntegerType'\n    operator<<(byte __b, _IntegerType __shift) noexcept\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:691:5: note: candidate template ignored: couldn't infer template argument '_Tp'\n    operator<<(_Ostream&& __os, const _Tp& __x)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/shared_ptr.h:66:5: note: candidate template ignored: couldn't infer template argument '_Tp'\n    operator<<(std::basic_ostream<_Ch, _Tr>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: couldn't infer template argument '_Dom'\n    _DEFINE_EXPR_BINARY_OPERATOR(<<, __shift_left)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:370:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const typename _Dom::value_type& __t,                  \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: couldn't infer template argument '_Dom'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:396:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const valarray<typename _Dom::value_type>& __v,        \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: couldn't infer template argument '_Tp'\n_DEFINE_BINARY_OPERATOR(<<, __shift_left)\n^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1177:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const typename valarray<_Tp>::value_type& __t,         \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n    _DEFINE_EXPR_BINARY_OPERATOR(<<, __shift_left)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:344:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom1, typename _Dom1::value_type>& __v,   \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:357:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom, typename _Dom::value_type>& __v,     \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:383:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom,typename _Dom::value_type>& __e,      \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: could not match 'valarray' against 'basic_ostream'\n_DEFINE_BINARY_OPERATOR(<<, __shift_left)\n^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1155:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const valarray<_Tp>& __v, const valarray<_Tp>& __w)    \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: could not match 'valarray' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1166:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const valarray<_Tp>& __v,                              \\\n    ^\ninput_line_16:11:50: error: reference to overloaded function could not be resolved; did you mean to call it?\n                      << \" memb_ = \" << memb_ << std::endl;\n                                                 ^~~~~~~~~\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:599:5: note: possible target for call\n    endl(basic_ostream<_CharT, _Traits>& __os)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:245:7: note: candidate function not viable: no overload of 'endl' matching 'const void *' for 1st argument\n      operator<<(const void* __p)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/string_view:580:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'basic_string_view<char, std::char_traits<char> >' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/system_error:217:5: note: candidate function not viable: no overload of 'endl' matching 'const std::error_code' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:117:7: note: candidate function not viable: no overload of 'endl' matching 'std::basic_ostream<char, std::char_traits<char> >::__ios_type &(*)(std::basic_ostream<char, std::char_traits<char> >::__ios_type &)' (aka 'basic_ios<char, std::char_traits<char> > &(*)(basic_ios<char, std::char_traits<char> > &)') for 1st argument\n      operator<<(__ios_type& (*__pf)(__ios_type&))\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:127:7: note: candidate function not viable: no overload of 'endl' matching 'std::ios_base &(*)(std::ios_base &)' for 1st argument\n      operator<<(ios_base& (*__pf) (ios_base&))\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:166:7: note: candidate function not viable: no overload of 'endl' matching 'long' for 1st argument\n      operator<<(long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:170:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned long' for 1st argument\n      operator<<(unsigned long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:174:7: note: candidate function not viable: no overload of 'endl' matching 'bool' for 1st argument\n      operator<<(bool __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:178:7: note: candidate function not viable: no overload of 'endl' matching 'short' for 1st argument\n      operator<<(short __n);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:181:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned short' for 1st argument\n      operator<<(unsigned short __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:189:7: note: candidate function not viable: no overload of 'endl' matching 'int' for 1st argument\n      operator<<(int __n);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:201:7: note: candidate function not viable: no overload of 'endl' matching 'long long' for 1st argument\n      operator<<(long long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:205:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned long long' for 1st argument\n      operator<<(unsigned long long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:220:7: note: candidate function not viable: no overload of 'endl' matching 'double' for 1st argument\n      operator<<(double __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:224:7: note: candidate function not viable: no overload of 'endl' matching 'float' for 1st argument\n      operator<<(float __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:232:7: note: candidate function not viable: no overload of 'endl' matching 'long double' for 1st argument\n      operator<<(long double __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:250:7: note: candidate function not viable: no overload of 'endl' matching 'std::nullptr_t' (aka 'nullptr_t') for 1st argument\n      operator<<(nullptr_t)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:276:7: note: candidate function not viable: no overload of 'endl' matching 'std::basic_ostream<char, std::char_traits<char> >::__streambuf_type *' (aka 'basic_streambuf<char, std::char_traits<char> > *') for 1st argument\n      operator<<(__streambuf_type* __sb);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:506:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:511:5: note: candidate function not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:517:5: note: candidate function not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:523:5: note: candidate function not viable: no overload of 'endl' matching 'signed char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, signed char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:528:5: note: candidate function not viable: no overload of 'endl' matching 'unsigned char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:548:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:565:5: note: candidate function not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:578:5: note: candidate function not viable: no overload of 'endl' matching 'const signed char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:583:5: note: candidate function not viable: no overload of 'endl' matching 'const unsigned char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/ostream.tcc:321:5: note: candidate function not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/basic_string.h:6419:5: note: candidate template ignored: couldn't infer template argument '_Alloc'\n    operator<<(basic_ostream<_CharT, _Traits>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/cstddef:130:5: note: candidate template ignored: couldn't infer template argument '_IntegerType'\n    operator<<(byte __b, _IntegerType __shift) noexcept\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:691:5: note: candidate template ignored: couldn't infer template argument '_Tp'\n    operator<<(_Ostream&& __os, const _Tp& __x)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/shared_ptr.h:66:5: note: candidate template ignored: couldn't infer template argument '_Tp'\n    operator<<(std::basic_ostream<_Ch, _Tr>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: couldn't infer template argument '_Dom'\n    _DEFINE_EXPR_BINARY_OPERATOR(<<, __shift_left)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:370:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const typename _Dom::value_type& __t,                  \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: couldn't infer template argument '_Dom'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:396:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const valarray<typename _Dom::value_type>& __v,        \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: couldn't infer template argument '_Tp'\n_DEFINE_BINARY_OPERATOR(<<, __shift_left)\n^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1177:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const typename valarray<_Tp>::value_type& __t,         \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n    _DEFINE_EXPR_BINARY_OPERATOR(<<, __shift_left)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:344:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom1, typename _Dom1::value_type>& __v,   \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:357:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom, typename _Dom::value_type>& __v,     \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:383:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom,typename _Dom::value_type>& __e,      \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: could not match 'valarray' against 'basic_ostream'\n_DEFINE_BINARY_OPERATOR(<<, __shift_left)\n^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1155:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const valarray<_Tp>& __v, const valarray<_Tp>& __w)    \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: could not match 'valarray' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1166:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const valarray<_Tp>& __v,                              \\\n    ^\nIn file included from input_line_5:1:\nIn file included from /srv/conda/envs/notebook/include/xeus/xinterpreter.hpp:17:\nIn file included from /srv/conda/envs/notebook/include/xeus/xcomm.hpp:19:\nIn file included from /srv/conda/envs/notebook/include/nlohmann/json.hpp:42:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/iterator:64:\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:568:8: error: no member named 'setstate' in 'std::basic_ostream<char>'\n        __out.setstate(ios_base::badbit);\n        ~~~~~ ^\ninput_line_16:5:23: note: in instantiation of function template specialization 'std::operator<<<std::char_traits<char> >' requested here\n            std::cout << \"An instance of myClass was generated.\"\n                      ^\n","output_type":"stream"},{"ename":"Interpreter Error","evalue":"","traceback":["Interpreter Error: "],"output_type":"error"}],"id":"3f4cf1f6-8c50-4057-ab71-259c1046222a"},{"cell_type":"code","source":"int main() {\n    myClass myObj1;\n    myClass myObj2( 5 );\n}\n\nmain();","metadata":{"trusted":true},"execution_count":8,"outputs":[{"name":"stderr","text":"input_line_17:2:5: error: unknown type name 'myClass'\n    myClass myObj1;\n    ^\ninput_line_17:3:5: error: unknown type name 'myClass'\n    myClass myObj2( 5 );\n    ^\n","output_type":"stream"},{"ename":"Interpreter Error","evalue":"","traceback":["Interpreter Error: "],"output_type":"error"}],"id":"51015ed7-9f4e-40c0-bfa9-2b9f98cd0e1e"},{"cell_type":"markdown","source":"#### Constructor Delegation","metadata":{},"id":"ee95a999-1b5a-4c1b-b2a3-d7dc9a6b306f"},{"cell_type":"markdown","source":"In the example above the body of both constructors is identical. Such a code duplication is, of course, not nice and in violation of the **D**on't **R**epeat **Y**ourself principle. We can avoid this by using **constructor delegation**.","metadata":{},"id":"b977d057-634f-4027-a177-6866bf88160b"},{"cell_type":"code","source":"#include <iostream>\n\nclass myClass{\n    \n    public:\n        myClass( int member ) : memb_(member) {\n            std::cout << \"An instance of myClass was generated.\"\n                      << \" memb_ = \" << memb_ << std::endl;\n        }\n\n        myClass() : myClass(0) {}\n        \n    private:\n        int memb_;\n};","metadata":{"trusted":true},"execution_count":9,"outputs":[{"name":"stderr","text":"input_line_19:6:50: error: reference to overloaded function could not be resolved; did you mean to call it?\n                      << \" memb_ = \" << memb_ << std::endl;\n                                                 ^~~~~~~~~\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:599:5: note: possible target for call\n    endl(basic_ostream<_CharT, _Traits>& __os)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:245:7: note: candidate function not viable: no overload of 'endl' matching 'const void *' for 1st argument\n      operator<<(const void* __p)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/string_view:580:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'basic_string_view<char, std::char_traits<char> >' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/system_error:217:5: note: candidate function not viable: no overload of 'endl' matching 'const std::error_code' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:117:7: note: candidate function not viable: no overload of 'endl' matching 'std::basic_ostream<char, std::char_traits<char> >::__ios_type &(*)(std::basic_ostream<char, std::char_traits<char> >::__ios_type &)' (aka 'basic_ios<char, std::char_traits<char> > &(*)(basic_ios<char, std::char_traits<char> > &)') for 1st argument\n      operator<<(__ios_type& (*__pf)(__ios_type&))\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:127:7: note: candidate function not viable: no overload of 'endl' matching 'std::ios_base &(*)(std::ios_base &)' for 1st argument\n      operator<<(ios_base& (*__pf) (ios_base&))\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:166:7: note: candidate function not viable: no overload of 'endl' matching 'long' for 1st argument\n      operator<<(long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:170:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned long' for 1st argument\n      operator<<(unsigned long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:174:7: note: candidate function not viable: no overload of 'endl' matching 'bool' for 1st argument\n      operator<<(bool __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:178:7: note: candidate function not viable: no overload of 'endl' matching 'short' for 1st argument\n      operator<<(short __n);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:181:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned short' for 1st argument\n      operator<<(unsigned short __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:189:7: note: candidate function not viable: no overload of 'endl' matching 'int' for 1st argument\n      operator<<(int __n);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:201:7: note: candidate function not viable: no overload of 'endl' matching 'long long' for 1st argument\n      operator<<(long long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:205:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned long long' for 1st argument\n      operator<<(unsigned long long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:220:7: note: candidate function not viable: no overload of 'endl' matching 'double' for 1st argument\n      operator<<(double __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:224:7: note: candidate function not viable: no overload of 'endl' matching 'float' for 1st argument\n      operator<<(float __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:232:7: note: candidate function not viable: no overload of 'endl' matching 'long double' for 1st argument\n      operator<<(long double __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:250:7: note: candidate function not viable: no overload of 'endl' matching 'std::nullptr_t' (aka 'nullptr_t') for 1st argument\n      operator<<(nullptr_t)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:276:7: note: candidate function not viable: no overload of 'endl' matching 'std::basic_ostream<char, std::char_traits<char> >::__streambuf_type *' (aka 'basic_streambuf<char, std::char_traits<char> > *') for 1st argument\n      operator<<(__streambuf_type* __sb);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:506:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:511:5: note: candidate function not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:517:5: note: candidate function not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:523:5: note: candidate function not viable: no overload of 'endl' matching 'signed char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, signed char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:528:5: note: candidate function not viable: no overload of 'endl' matching 'unsigned char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:548:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:565:5: note: candidate function not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:578:5: note: candidate function not viable: no overload of 'endl' matching 'const signed char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:583:5: note: candidate function not viable: no overload of 'endl' matching 'const unsigned char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/ostream.tcc:321:5: note: candidate function not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/basic_string.h:6419:5: note: candidate template ignored: couldn't infer template argument '_Alloc'\n    operator<<(basic_ostream<_CharT, _Traits>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/cstddef:130:5: note: candidate template ignored: couldn't infer template argument '_IntegerType'\n    operator<<(byte __b, _IntegerType __shift) noexcept\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:691:5: note: candidate template ignored: couldn't infer template argument '_Tp'\n    operator<<(_Ostream&& __os, const _Tp& __x)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/shared_ptr.h:66:5: note: candidate template ignored: couldn't infer template argument '_Tp'\n    operator<<(std::basic_ostream<_Ch, _Tr>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: couldn't infer template argument '_Dom'\n    _DEFINE_EXPR_BINARY_OPERATOR(<<, __shift_left)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:370:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const typename _Dom::value_type& __t,                  \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: couldn't infer template argument '_Dom'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:396:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const valarray<typename _Dom::value_type>& __v,        \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: couldn't infer template argument '_Tp'\n_DEFINE_BINARY_OPERATOR(<<, __shift_left)\n^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1177:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const typename valarray<_Tp>::value_type& __t,         \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n    _DEFINE_EXPR_BINARY_OPERATOR(<<, __shift_left)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:344:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom1, typename _Dom1::value_type>& __v,   \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:357:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom, typename _Dom::value_type>& __v,     \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:383:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom,typename _Dom::value_type>& __e,      \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: could not match 'valarray' against 'basic_ostream'\n_DEFINE_BINARY_OPERATOR(<<, __shift_left)\n^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1155:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const valarray<_Tp>& __v, const valarray<_Tp>& __w)    \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: could not match 'valarray' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1166:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const valarray<_Tp>& __v,                              \\\n    ^\nIn file included from input_line_5:1:\nIn file included from /srv/conda/envs/notebook/include/xeus/xinterpreter.hpp:17:\nIn file included from /srv/conda/envs/notebook/include/xeus/xcomm.hpp:19:\nIn file included from /srv/conda/envs/notebook/include/nlohmann/json.hpp:42:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/iterator:64:\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:568:8: error: no member named 'setstate' in 'std::basic_ostream<char>'\n        __out.setstate(ios_base::badbit);\n        ~~~~~ ^\ninput_line_19:5:23: note: in instantiation of function template specialization 'std::operator<<<std::char_traits<char> >' requested here\n            std::cout << \"An instance of myClass was generated.\"\n                      ^\n","output_type":"stream"},{"ename":"Interpreter Error","evalue":"","traceback":["Interpreter Error: "],"output_type":"error"}],"id":"8eed6ec9-9ad6-48ab-b0e2-ab0ea35b9b57"},{"cell_type":"markdown","source":"#### Cleaning up: Destructors\nWhen an object goes out of scope and is destroyed we might want or need to do some housekeeping. For this we can implement a destructor.","metadata":{},"id":"fa5b47ea-8d12-4f55-8efe-c08588b81dbc"},{"cell_type":"code","source":"#include <iostream>\n\nclass VerboseClass{\n    \n    public:\n        // c'tor\n        VerboseClass() {\n            std::cout << \"An instance of VerboseClass was generated.\" << std::endl;\n        }\n\n        // d'tor\n        ~VerboseClass() {\n            std::cout << \"An instance of VerboseClass was destroyed.\\n\" << std::endl;\n        }\n};","metadata":{"trusted":true},"execution_count":10,"outputs":[{"name":"stderr","text":"input_line_21:6:74: error: reference to overloaded function could not be resolved; did you mean to call it?\n            std::cout << \"An instance of VerboseClass was generated.\" << std::endl;\n                                                                         ^~~~~~~~~\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:599:5: note: possible target for call\n    endl(basic_ostream<_CharT, _Traits>& __os)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:245:7: note: candidate function not viable: no overload of 'endl' matching 'const void *' for 1st argument\n      operator<<(const void* __p)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/string_view:580:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'basic_string_view<char, std::char_traits<char> >' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/system_error:217:5: note: candidate function not viable: no overload of 'endl' matching 'const std::error_code' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:117:7: note: candidate function not viable: no overload of 'endl' matching 'std::basic_ostream<char, std::char_traits<char> >::__ios_type &(*)(std::basic_ostream<char, std::char_traits<char> >::__ios_type &)' (aka 'basic_ios<char, std::char_traits<char> > &(*)(basic_ios<char, std::char_traits<char> > &)') for 1st argument\n      operator<<(__ios_type& (*__pf)(__ios_type&))\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:127:7: note: candidate function not viable: no overload of 'endl' matching 'std::ios_base &(*)(std::ios_base &)' for 1st argument\n      operator<<(ios_base& (*__pf) (ios_base&))\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:166:7: note: candidate function not viable: no overload of 'endl' matching 'long' for 1st argument\n      operator<<(long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:170:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned long' for 1st argument\n      operator<<(unsigned long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:174:7: note: candidate function not viable: no overload of 'endl' matching 'bool' for 1st argument\n      operator<<(bool __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:178:7: note: candidate function not viable: no overload of 'endl' matching 'short' for 1st argument\n      operator<<(short __n);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:181:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned short' for 1st argument\n      operator<<(unsigned short __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:189:7: note: candidate function not viable: no overload of 'endl' matching 'int' for 1st argument\n      operator<<(int __n);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:201:7: note: candidate function not viable: no overload of 'endl' matching 'long long' for 1st argument\n      operator<<(long long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:205:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned long long' for 1st argument\n      operator<<(unsigned long long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:220:7: note: candidate function not viable: no overload of 'endl' matching 'double' for 1st argument\n      operator<<(double __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:224:7: note: candidate function not viable: no overload of 'endl' matching 'float' for 1st argument\n      operator<<(float __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:232:7: note: candidate function not viable: no overload of 'endl' matching 'long double' for 1st argument\n      operator<<(long double __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:250:7: note: candidate function not viable: no overload of 'endl' matching 'std::nullptr_t' (aka 'nullptr_t') for 1st argument\n      operator<<(nullptr_t)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:276:7: note: candidate function not viable: no overload of 'endl' matching 'std::basic_ostream<char, std::char_traits<char> >::__streambuf_type *' (aka 'basic_streambuf<char, std::char_traits<char> > *') for 1st argument\n      operator<<(__streambuf_type* __sb);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:506:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:511:5: note: candidate function not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:517:5: note: candidate function not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:523:5: note: candidate function not viable: no overload of 'endl' matching 'signed char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, signed char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:528:5: note: candidate function not viable: no overload of 'endl' matching 'unsigned char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:548:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:565:5: note: candidate function not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:578:5: note: candidate function not viable: no overload of 'endl' matching 'const signed char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:583:5: note: candidate function not viable: no overload of 'endl' matching 'const unsigned char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/ostream.tcc:321:5: note: candidate function not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/basic_string.h:6419:5: note: candidate template ignored: couldn't infer template argument '_Alloc'\n    operator<<(basic_ostream<_CharT, _Traits>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/cstddef:130:5: note: candidate template ignored: couldn't infer template argument '_IntegerType'\n    operator<<(byte __b, _IntegerType __shift) noexcept\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:691:5: note: candidate template ignored: couldn't infer template argument '_Tp'\n    operator<<(_Ostream&& __os, const _Tp& __x)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/shared_ptr.h:66:5: note: candidate template ignored: couldn't infer template argument '_Tp'\n    operator<<(std::basic_ostream<_Ch, _Tr>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: couldn't infer template argument '_Dom'\n    _DEFINE_EXPR_BINARY_OPERATOR(<<, __shift_left)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:370:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const typename _Dom::value_type& __t,                  \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: couldn't infer template argument '_Dom'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:396:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const valarray<typename _Dom::value_type>& __v,        \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: couldn't infer template argument '_Tp'\n_DEFINE_BINARY_OPERATOR(<<, __shift_left)\n^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1177:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const typename valarray<_Tp>::value_type& __t,         \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n    _DEFINE_EXPR_BINARY_OPERATOR(<<, __shift_left)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:344:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom1, typename _Dom1::value_type>& __v,   \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:357:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom, typename _Dom::value_type>& __v,     \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:383:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom,typename _Dom::value_type>& __e,      \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: could not match 'valarray' against 'basic_ostream'\n_DEFINE_BINARY_OPERATOR(<<, __shift_left)\n^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1155:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const valarray<_Tp>& __v, const valarray<_Tp>& __w)    \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: could not match 'valarray' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1166:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const valarray<_Tp>& __v,                              \\\n    ^\nIn file included from input_line_1:1:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/new:40:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/exception:144:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/nested_exception.h:40:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/move.h:55:\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/type_traits:137:31: error: no member named 'value' in 'std::__not_<std::is_lvalue_reference<std::basic_ostream<char> &> >'\n    : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type\n                         ~~~~~^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:685:24: note: in instantiation of template class 'std::__and_<std::__not_<std::is_lvalue_reference<std::basic_ostream<char> &> >, std::__is_convertible_to_basic_ostream<std::basic_ostream<char> &>, std::__is_insertable<std::basic_ostream<char> &, char const (&)[44], void> >' requested here\n    typename enable_if<__and_<__not_<is_lvalue_reference<_Ostream>>,\n                       ^\ninput_line_21:10:23: note: while substituting deduced template arguments into function template 'operator<<' [with _Ostream = std::basic_ostream<char> &, _Tp = char [44]]\n            std::cout << \"An instance of VerboseClass was destroyed.\\n\" << std::endl;\n                      ^\ninput_line_21:10:76: error: reference to overloaded function could not be resolved; did you mean to call it?\n            std::cout << \"An instance of VerboseClass was destroyed.\\n\" << std::endl;\n                                                                           ^~~~~~~~~\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:599:5: note: possible target for call\n    endl(basic_ostream<_CharT, _Traits>& __os)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:245:7: note: candidate function not viable: no overload of 'endl' matching 'const void *' for 1st argument\n      operator<<(const void* __p)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/string_view:580:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'basic_string_view<char, std::char_traits<char> >' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/system_error:217:5: note: candidate function not viable: no overload of 'endl' matching 'const std::error_code' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:117:7: note: candidate function not viable: no overload of 'endl' matching 'std::basic_ostream<char, std::char_traits<char> >::__ios_type &(*)(std::basic_ostream<char, std::char_traits<char> >::__ios_type &)' (aka 'basic_ios<char, std::char_traits<char> > &(*)(basic_ios<char, std::char_traits<char> > &)') for 1st argument\n      operator<<(__ios_type& (*__pf)(__ios_type&))\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:127:7: note: candidate function not viable: no overload of 'endl' matching 'std::ios_base &(*)(std::ios_base &)' for 1st argument\n      operator<<(ios_base& (*__pf) (ios_base&))\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:166:7: note: candidate function not viable: no overload of 'endl' matching 'long' for 1st argument\n      operator<<(long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:170:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned long' for 1st argument\n      operator<<(unsigned long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:174:7: note: candidate function not viable: no overload of 'endl' matching 'bool' for 1st argument\n      operator<<(bool __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:178:7: note: candidate function not viable: no overload of 'endl' matching 'short' for 1st argument\n      operator<<(short __n);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:181:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned short' for 1st argument\n      operator<<(unsigned short __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:189:7: note: candidate function not viable: no overload of 'endl' matching 'int' for 1st argument\n      operator<<(int __n);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:201:7: note: candidate function not viable: no overload of 'endl' matching 'long long' for 1st argument\n      operator<<(long long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:205:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned long long' for 1st argument\n      operator<<(unsigned long long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:220:7: note: candidate function not viable: no overload of 'endl' matching 'double' for 1st argument\n      operator<<(double __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:224:7: note: candidate function not viable: no overload of 'endl' matching 'float' for 1st argument\n      operator<<(float __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:232:7: note: candidate function not viable: no overload of 'endl' matching 'long double' for 1st argument\n      operator<<(long double __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:250:7: note: candidate function not viable: no overload of 'endl' matching 'std::nullptr_t' (aka 'nullptr_t') for 1st argument\n      operator<<(nullptr_t)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:276:7: note: candidate function not viable: no overload of 'endl' matching 'std::basic_ostream<char, std::char_traits<char> >::__streambuf_type *' (aka 'basic_streambuf<char, std::char_traits<char> > *') for 1st argument\n      operator<<(__streambuf_type* __sb);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:506:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:511:5: note: candidate function not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:517:5: note: candidate function not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:523:5: note: candidate function not viable: no overload of 'endl' matching 'signed char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, signed char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:528:5: note: candidate function not viable: no overload of 'endl' matching 'unsigned char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:548:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:565:5: note: candidate function not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:578:5: note: candidate function not viable: no overload of 'endl' matching 'const signed char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:583:5: note: candidate function not viable: no overload of 'endl' matching 'const unsigned char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/ostream.tcc:321:5: note: candidate function not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/basic_string.h:6419:5: note: candidate template ignored: couldn't infer template argument '_Alloc'\n    operator<<(basic_ostream<_CharT, _Traits>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/cstddef:130:5: note: candidate template ignored: couldn't infer template argument '_IntegerType'\n    operator<<(byte __b, _IntegerType __shift) noexcept\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:691:5: note: candidate template ignored: couldn't infer template argument '_Tp'\n    operator<<(_Ostream&& __os, const _Tp& __x)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/shared_ptr.h:66:5: note: candidate template ignored: couldn't infer template argument '_Tp'\n    operator<<(std::basic_ostream<_Ch, _Tr>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: couldn't infer template argument '_Dom'\n    _DEFINE_EXPR_BINARY_OPERATOR(<<, __shift_left)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:370:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const typename _Dom::value_type& __t,                  \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: couldn't infer template argument '_Dom'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:396:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const valarray<typename _Dom::value_type>& __v,        \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: couldn't infer template argument '_Tp'\n_DEFINE_BINARY_OPERATOR(<<, __shift_left)\n^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1177:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const typename valarray<_Tp>::value_type& __t,         \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n    _DEFINE_EXPR_BINARY_OPERATOR(<<, __shift_left)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:344:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom1, typename _Dom1::value_type>& __v,   \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:357:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom, typename _Dom::value_type>& __v,     \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:383:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom,typename _Dom::value_type>& __e,      \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: could not match 'valarray' against 'basic_ostream'\n_DEFINE_BINARY_OPERATOR(<<, __shift_left)\n^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1155:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const valarray<_Tp>& __v, const valarray<_Tp>& __w)    \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: could not match 'valarray' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1166:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const valarray<_Tp>& __v,                              \\\n    ^\nIn file included from input_line_5:1:\nIn file included from /srv/conda/envs/notebook/include/xeus/xinterpreter.hpp:17:\nIn file included from /srv/conda/envs/notebook/include/xeus/xcomm.hpp:19:\nIn file included from /srv/conda/envs/notebook/include/nlohmann/json.hpp:42:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/iterator:64:\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:568:8: error: no member named 'setstate' in 'std::basic_ostream<char>'\n        __out.setstate(ios_base::badbit);\n        ~~~~~ ^\ninput_line_21:6:23: note: in instantiation of function template specialization 'std::operator<<<std::char_traits<char> >' requested here\n            std::cout << \"An instance of VerboseClass was generated.\" << std::endl;\n                      ^\n","output_type":"stream"},{"ename":"Interpreter Error","evalue":"","traceback":["Interpreter Error: "],"output_type":"error"}],"id":"e456ce69-71e5-4169-b3e8-f302c3f72242"},{"cell_type":"code","source":"int main() {\n    for( int k = 0; k < 3; k++ ) {\n        VerboseClass talky;\n    }\n}\n\nmain();","metadata":{"trusted":true},"execution_count":11,"outputs":[{"name":"stderr","text":"input_line_22:3:9: error: unknown type name 'VerboseClass'\n        VerboseClass talky;\n        ^\n","output_type":"stream"},{"ename":"Interpreter Error","evalue":"","traceback":["Interpreter Error: "],"output_type":"error"}],"id":"8fe56e9c-1842-4c29-84eb-1b20b3f7704a"},{"cell_type":"markdown","source":"#### Small Project: A Vector Class for Linear Algebra\nTasks:\n- We want to implement a class that represents a vector entity from linear algebra.\n- The size of the vector should be selectable at object creation -> need to allocate memory dynamically.\n- Access to vector entries should be 1-based -> operator overloading.\n- Implement simple methods, such as\n  - scaling vector with a constant\n  - adding two vectors together\n  - compute the Euclidean inner product of two vectors","metadata":{},"id":"dffe4043-6959-4169-b0df-203a50d36e0f"},{"cell_type":"code","source":"// --------------------------------------\n//  Start with the skeleton of the class\n// --------------------------------------\n\n#include <iostream>\n#include <cassert>\n\nclass VectorClass{\n    \n    public:\n    \n        // User should specify dimension at object creation\n        VectorClass( unsigned int dim ) : dim_(dim) {\n            \n            // don't allow vectors with zero dimension\n            assert( dim_ > 0 );\n\n            // allocate memory (will throw an exception, if it fails)\n            vec_ = new double[ dim_ ];\n            \n            // be talkative ;-)\n            std::cout << \"An instance of VectorClass was generated. dim_ = \" << dim_ << std::endl;\n        }\n\n        // Don't allow the default constructor [prior to C++11 you would solve this by making it private]\n        VectorClass() = delete;\n\n    private:\n        unsigned int dim_;   // dimension of vector\n        double* vec_;        // entries of vector\n};","metadata":{"trusted":true},"execution_count":12,"outputs":[{"name":"stderr","text":"In file included from input_line_1:1:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/new:40:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/exception:144:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/nested_exception.h:40:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/move.h:55:\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/type_traits:137:31: error: no member named 'value' in 'std::__not_<std::is_lvalue_reference<std::basic_ostream<char> &> >'\n    : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type\n                         ~~~~~^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:685:24: note: in instantiation of template class 'std::__and_<std::__not_<std::is_lvalue_reference<std::basic_ostream<char> &> >, std::__is_convertible_to_basic_ostream<std::basic_ostream<char> &>, std::__is_insertable<std::basic_ostream<char> &, char const (&)[50], void> >' requested here\n    typename enable_if<__and_<__not_<is_lvalue_reference<_Ostream>>,\n                       ^\ninput_line_25:14:23: note: while substituting deduced template arguments into function template 'operator<<' [with _Ostream = std::basic_ostream<char> &, _Tp = char [50]]\n            std::cout << \"An instance of VectorClass was generated. dim_ = \" << dim_ << std::endl;\n                      ^\ninput_line_25:14:78: error: use of overloaded operator '<<' is ambiguous (with operand types 'basic_ostream<char, std::char_traits<char> >' and 'unsigned int')\n            std::cout << \"An instance of VectorClass was generated. dim_ = \" << dim_ << std::endl;\n            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:166:7: note: candidate function\n      operator<<(long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:170:7: note: candidate function\n      operator<<(unsigned long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:174:7: note: candidate function\n      operator<<(bool __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:178:7: note: candidate function\n      operator<<(short __n);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:181:7: note: candidate function\n      operator<<(unsigned short __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:189:7: note: candidate function\n      operator<<(int __n);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:201:7: note: candidate function\n      operator<<(long long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:205:7: note: candidate function\n      operator<<(unsigned long long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:220:7: note: candidate function\n      operator<<(double __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:224:7: note: candidate function\n      operator<<(float __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:232:7: note: candidate function\n      operator<<(long double __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:517:5: note: candidate function [with _Traits = std::char_traits<char>]\n    operator<<(basic_ostream<char, _Traits>& __out, char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:511:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>]\n    operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:523:5: note: candidate function [with _Traits = std::char_traits<char>]\n    operator<<(basic_ostream<char, _Traits>& __out, signed char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:528:5: note: candidate function [with _Traits = std::char_traits<char>]\n    operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:568:8: error: no member named 'setstate' in 'std::basic_ostream<char>'\n        __out.setstate(ios_base::badbit);\n        ~~~~~ ^\ninput_line_25:14:23: note: in instantiation of function template specialization 'std::operator<<<std::char_traits<char> >' requested here\n            std::cout << \"An instance of VectorClass was generated. dim_ = \" << dim_ << std::endl;\n                      ^\n","output_type":"stream"},{"ename":"Interpreter Error","evalue":"","traceback":["Interpreter Error: "],"output_type":"error"}],"id":"f33e5eef-b396-4bfc-8031-f21b33839611"},{"cell_type":"code","source":"int main() {\n    VectorClass myVec( 10 );\n}","metadata":{"trusted":true},"execution_count":13,"outputs":[{"name":"stderr","text":"input_line_26:2:5: error: unknown type name 'VectorClass'\n    VectorClass myVec( 10 );\n    ^\n","output_type":"stream"},{"ename":"Interpreter Error","evalue":"","traceback":["Interpreter Error: "],"output_type":"error"}],"id":"e2f2ac16-a0df-4f6c-816a-cb47420f4989"},{"cell_type":"code","source":"main();","metadata":{"trusted":true},"execution_count":14,"outputs":[{"name":"stderr","text":"input_line_27:2:2: error: use of undeclared identifier 'main'\n main();\n ^\n","output_type":"stream"},{"ename":"Interpreter Error","evalue":"","traceback":["Interpreter Error: "],"output_type":"error"}],"id":"7c06f924-8412-449c-a5b5-a56b1df2ff2b"},{"cell_type":"markdown","source":"Our implementation is **missing an essential piece**? What could that be?","metadata":{},"id":"935b6f8d-d347-4edb-9807-f2ed3563dcaf"},{"cell_type":"code","source":"// --------------------------------------\n//  Start with the skeleton of the class\n// --------------------------------------\n\n#include <iostream>\n#include <cassert>\n\nclass VectorClass{\n    \n    public:\n    \n        // User should specify dimension at object creation\n        VectorClass( unsigned int dim ) : dim_(dim) {\n            \n            // don't allow vectors with zero dimension\n            assert( dim_ > 0 );\n\n            // allocate memory (will throw an exception, if it fails)\n            vec_ = new double[ dim_ ];\n            \n            // be talkative ;-)\n            std::cout << \"An instance of VectorClass was generated. dim_ = \" << dim_ << std::endl;\n        }\n\n        // Don't allow the default constructor [prior to C++11 you would solve this by making it private]\n        VectorClass() = delete;\n    \n        // We need to implement a destructor to free the dynamic memory again, otherwise we easily produce\n        // memory leaks\n        ~VectorClass() {\n            delete[] vec_;\n            std::cout << \"An instance of VectorClass was destroyed and \" << dim_ * sizeof(double)\n                      << \" bytes freed.\" << std::endl;\n        }\n\n    private:\n        unsigned int dim_;   // dimension of vector\n        double* vec_;        // entries of vector\n};","metadata":{"trusted":true},"execution_count":null,"outputs":[{"name":"stderr","text":"input_line_30:14:78: error: use of overloaded operator '<<' is ambiguous (with operand types 'basic_ostream<char, std::char_traits<char> >' and 'unsigned int')\n            std::cout << \"An instance of VectorClass was generated. dim_ = \" << dim_ << std::endl;\n            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:166:7: note: candidate function\n      operator<<(long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:170:7: note: candidate function\n      operator<<(unsigned long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:174:7: note: candidate function\n      operator<<(bool __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:178:7: note: candidate function\n      operator<<(short __n);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:181:7: note: candidate function\n      operator<<(unsigned short __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:189:7: note: candidate function\n      operator<<(int __n);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:201:7: note: candidate function\n      operator<<(long long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:205:7: note: candidate function\n      operator<<(unsigned long long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:220:7: note: candidate function\n      operator<<(double __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:224:7: note: candidate function\n      operator<<(float __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:232:7: note: candidate function\n      operator<<(long double __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:517:5: note: candidate function [with _Traits = std::char_traits<char>]\n    operator<<(basic_ostream<char, _Traits>& __out, char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:511:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>]\n    operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:523:5: note: candidate function [with _Traits = std::char_traits<char>]\n    operator<<(basic_ostream<char, _Traits>& __out, signed char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:528:5: note: candidate function [with _Traits = std::char_traits<char>]\n    operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)\n    ^\nIn file included from input_line_1:1:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/new:40:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/exception:144:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/nested_exception.h:40:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/move.h:55:\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/type_traits:137:31: error: no member named 'value' in 'std::__not_<std::is_lvalue_reference<std::basic_ostream<char> &> >'\n    : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type\n                         ~~~~~^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:685:24: note: in instantiation of template class 'std::__and_<std::__not_<std::is_lvalue_reference<std::basic_ostream<char> &> >, std::__is_convertible_to_basic_ostream<std::basic_ostream<char> &>, std::__is_insertable<std::basic_ostream<char> &, char const (&)[46], void> >' requested here\n    typename enable_if<__and_<__not_<is_lvalue_reference<_Ostream>>,\n                       ^\ninput_line_30:23:23: note: while substituting deduced template arguments into function template 'operator<<' [with _Ostream = std::basic_ostream<char> &, _Tp = char [46]]\n            std::cout << \"An instance of VectorClass was destroyed and \" << dim_ * sizeof(double)\n                      ^\nIn file included from input_line_1:1:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/new:40:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/exception:144:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/nested_exception.h:40:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/move.h:55:\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/type_traits:137:31: error: no member named 'value' in 'std::__not_<std::is_lvalue_reference<std::basic_ostream<char> &> >'\n    : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type\n                         ~~~~~^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:685:24: note: in instantiation of template class 'std::__and_<std::__not_<std::is_lvalue_reference<std::basic_ostream<char> &> >, std::__is_convertible_to_basic_ostream<std::basic_ostream<char> &>, std::__is_insertable<std::basic_ostream<char> &, char const (&)[14], void> >' requested here\n    typename enable_if<__and_<__not_<is_lvalue_reference<_Ostream>>,\n                       ^\ninput_line_30:24:23: note: while substituting deduced template arguments into function template 'operator<<' [with _Ostream = std::basic_ostream<char> &, _Tp = char [14]]\n                      << \" bytes freed.\" << std::endl;\n                      ^\ninput_line_30:24:45: error: reference to overloaded function could not be resolved; did you mean to call it?\n                      << \" bytes freed.\" << std::endl;\n                                            ^~~~~~~~~\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:599:5: note: possible target for call\n    endl(basic_ostream<_CharT, _Traits>& __os)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:245:7: note: candidate function not viable: no overload of 'endl' matching 'const void *' for 1st argument\n      operator<<(const void* __p)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/string_view:580:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'basic_string_view<char, std::char_traits<char> >' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/system_error:217:5: note: candidate function not viable: no overload of 'endl' matching 'const std::error_code' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:117:7: note: candidate function not viable: no overload of 'endl' matching 'std::basic_ostream<char, std::char_traits<char> >::__ios_type &(*)(std::basic_ostream<char, std::char_traits<char> >::__ios_type &)' (aka 'basic_ios<char, std::char_traits<char> > &(*)(basic_ios<char, std::char_traits<char> > &)') for 1st argument\n      operator<<(__ios_type& (*__pf)(__ios_type&))\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:127:7: note: candidate function not viable: no overload of 'endl' matching 'std::ios_base &(*)(std::ios_base &)' for 1st argument\n      operator<<(ios_base& (*__pf) (ios_base&))\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:166:7: note: candidate function not viable: no overload of 'endl' matching 'long' for 1st argument\n      operator<<(long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:170:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned long' for 1st argument\n      operator<<(unsigned long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:174:7: note: candidate function not viable: no overload of 'endl' matching 'bool' for 1st argument\n      operator<<(bool __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:178:7: note: candidate function not viable: no overload of 'endl' matching 'short' for 1st argument\n      operator<<(short __n);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:181:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned short' for 1st argument\n      operator<<(unsigned short __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:189:7: note: candidate function not viable: no overload of 'endl' matching 'int' for 1st argument\n      operator<<(int __n);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:201:7: note: candidate function not viable: no overload of 'endl' matching 'long long' for 1st argument\n      operator<<(long long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:205:7: note: candidate function not viable: no overload of 'endl' matching 'unsigned long long' for 1st argument\n      operator<<(unsigned long long __n)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:220:7: note: candidate function not viable: no overload of 'endl' matching 'double' for 1st argument\n      operator<<(double __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:224:7: note: candidate function not viable: no overload of 'endl' matching 'float' for 1st argument\n      operator<<(float __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:232:7: note: candidate function not viable: no overload of 'endl' matching 'long double' for 1st argument\n      operator<<(long double __f)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:250:7: note: candidate function not viable: no overload of 'endl' matching 'std::nullptr_t' (aka 'nullptr_t') for 1st argument\n      operator<<(nullptr_t)\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:276:7: note: candidate function not viable: no overload of 'endl' matching 'std::basic_ostream<char, std::char_traits<char> >::__streambuf_type *' (aka 'basic_streambuf<char, std::char_traits<char> > *') for 1st argument\n      operator<<(__streambuf_type* __sb);\n      ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:506:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:511:5: note: candidate function not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:517:5: note: candidate function not viable: no overload of 'endl' matching 'char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:523:5: note: candidate function not viable: no overload of 'endl' matching 'signed char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, signed char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:528:5: note: candidate function not viable: no overload of 'endl' matching 'unsigned char' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:548:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>] not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:565:5: note: candidate function not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:578:5: note: candidate function not viable: no overload of 'endl' matching 'const signed char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:583:5: note: candidate function not viable: no overload of 'endl' matching 'const unsigned char *' for 2nd argument\n    operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/ostream.tcc:321:5: note: candidate function not viable: no overload of 'endl' matching 'const char *' for 2nd argument\n    operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/basic_string.h:6419:5: note: candidate template ignored: couldn't infer template argument '_Alloc'\n    operator<<(basic_ostream<_CharT, _Traits>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/cstddef:130:5: note: candidate template ignored: couldn't infer template argument '_IntegerType'\n    operator<<(byte __b, _IntegerType __shift) noexcept\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/ostream:691:5: note: candidate template ignored: couldn't infer template argument '_Tp'\n    operator<<(_Ostream&& __os, const _Tp& __x)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/shared_ptr.h:66:5: note: candidate template ignored: couldn't infer template argument '_Tp'\n    operator<<(std::basic_ostream<_Ch, _Tr>& __os,\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: couldn't infer template argument '_Dom'\n    _DEFINE_EXPR_BINARY_OPERATOR(<<, __shift_left)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:370:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const typename _Dom::value_type& __t,                  \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: couldn't infer template argument '_Dom'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:396:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const valarray<typename _Dom::value_type>& __v,        \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1193:1: note: candidate template ignored: couldn't infer template argument '_Tp'\n_DEFINE_BINARY_OPERATOR(<<, __shift_left)\n^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/valarray:1177:5: note: expanded from macro '_DEFINE_BINARY_OPERATOR'\n    operator _Op(const typename valarray<_Tp>::value_type& __t,         \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n    _DEFINE_EXPR_BINARY_OPERATOR(<<, __shift_left)\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:344:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom1, typename _Dom1::value_type>& __v,   \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413:5: note: candidate template ignored: could not match '_Expr' against 'basic_ostream'\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:357:5: note: expanded from macro '_DEFINE_EXPR_BINARY_OPERATOR'\n    operator _Op(const _Expr<_Dom, typename _Dom::value_type>& __v,     \\\n    ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/valarray_after.h:413","output_type":"stream"}],"id":"102897af-957e-43b7-a959-eb6ee468f35d"},{"cell_type":"code","source":"int main() {\n    VectorClass myVec( 10 );\n}\n\nmain();","metadata":{"trusted":true},"execution_count":null,"outputs":[],"id":"adcac578-0bca-4aed-8d13-4514826dd0e7"},{"cell_type":"markdown","source":"Our VectorClass is currently pretty useless, since we cannot manipulate the values of the vector entries. Making vec_ public would break encapsulation. Instead let's\n- overload the [ ] for providing one-based access\n- add a getter method for the dimension\n- add a member function to pretty-print the vector's entries","metadata":{},"id":"1a74105b-5453-49ab-aeed-e0371809fc52"},{"cell_type":"code","source":"#include <iostream>\n#include <cassert>\n\nclass VectorClass{\n    \n    public:\n    \n        // User should specify dimension at object creation\n        VectorClass( unsigned int dim ) : dim_(dim) {\n            \n            // don't allow vectors with zero dimension\n            assert( dim_ > 0 );\n\n            // allocate memory (will throw an exception, if it fails)\n            vec_ = new double[ dim_ ];\n            \n            // be talkative ;-)\n            std::cout << \"An instance of VectorClass was generated. dim_ = \" << dim_ << std::endl;\n        }\n\n        // Don't allow the default constructor [prior to C++11 you would solve this by making it private]\n        VectorClass() = delete;\n    \n        // We need to implement a destructor to free the dynamic memory again, otherwise we easily produce\n        // memory leaks\n        ~VectorClass() {\n            delete[] vec_;\n            std::cout << \"An instance of VectorClass was destroyed and \" << dim_ * sizeof(double)\n                      << \" bytes freed.\" << std::endl;\n        }\n\n        // provide access to the vector's dimension\n        unsigned int getDim() { return dim_; }\n    \n        // overload the [] for accessing individual entries\n        double& operator[] ( unsigned int index ){\n            assert( index != 0 && index <= dim_ );\n            return vec_[index-1];\n        }\n\n        // pretty print vector to given output stream\n        void print( std::ostream &os ) {\n            os << \"(\";\n            for( unsigned int k = 0; k < dim_-1; k++ ) {\n                os << vec_[k] << \", \";\n            }\n            os << vec_[dim_-1] << \")\" << std::endl;\n        }\n    \n    private:\n        unsigned int dim_;   // dimension of vector\n        double* vec_;        // entries of vector\n\n};","metadata":{"trusted":true},"execution_count":null,"outputs":[],"id":"a32eb08a-822a-4b83-b3d0-6de281acffba"},{"cell_type":"code","source":"// Let's test our extended class\n\nint main() {\n    \n    VectorClass myVec( 3 );\n    \n    myVec[ 1 ] = 3.0;\n    myVec[ 2 ] = 2.0;\n    myVec[ 3 ] = 1.0;\n    \n    myVec.print( std::cout );\n}\n\nmain();","metadata":{"trusted":true},"execution_count":null,"outputs":[],"id":"4eb50e73-21f5-4669-9464-32f11d958732"},{"cell_type":"markdown","source":"**What is left on our todo-list?**\nImplement simple methods, such as\n  - scaling vector with a constant\n  - adding two vectors together\n  - compute the Euclidean inner product of two vectors","metadata":{},"id":"d8af8c97-2855-41f9-bda2-9d5ae341b7c0"},{"cell_type":"code","source":"%%file VectorClass.cpp\n\n#include <iostream>\n#include <cassert>\n\nclass VectorClass{\n    \n    public:\n    \n        // User should specify dimension at object creation\n        VectorClass( unsigned int dim ) : dim_(dim) {\n            \n            // don't allow vectors with zero dimension\n            assert( dim_ > 0 );\n\n            // allocate memory (will throw an exception, if it fails)\n            vec_ = new double[ dim_ ];\n            \n            // be talkative ;-)\n            std::cout << \"An instance of VectorClass was generated. dim_ = \" << dim_ << std::endl;\n        }\n\n        // Don't allow the default constructor [prior to C++11 you would solve this by making it private]\n        VectorClass() = delete;\n    \n        // We need to implement a destructor to free the dynamic memory again, otherwise we easily produce\n        // memory leaks\n        ~VectorClass() {\n            delete[] vec_;\n            std::cout << \"An instance of VectorClass was destroyed and \" << dim_ * sizeof(double)\n                      << \" bytes freed.\" << std::endl;\n        }\n\n        // provide access to the vector's dimension\n        unsigned int getDim() { return dim_; }\n    \n        // overload the [] for accessing individual entries\n        double& operator[] ( unsigned int index ){\n            assert( index != 0 && index <= dim_ );\n            return vec_[index-1];\n        }\n\n        // pretty print vector to given output stream (default will be std::cout)\n        void print( std::ostream &os = std::cout ) {\n            os << \"(\";\n            for( unsigned int k = 0; k < dim_-1; k++ ) {\n                os << vec_[k] << \", \";\n            }\n            os << vec_[dim_-1] << \")\" << std::endl;\n        }\n    \n        // scale vector with a constant\n        void scale( double factor ) {\n            // leave that to students\n        }\n    \n        // add to vectors together (that's actually a little bit tricky, due to the question \"where to put the result?\"\n        // for the moment leave it with adding another vector to the one on which the method is called.\n    \n        // let us try the following, and determine, why it will fail ;-)\n        void add( VectorClass other ) {\n\n            // make sure that input vector has correct length\n            assert( other.getDim() == dim_ );\n            for( unsigned int k = 0; k < dim_; k++ ) {\n                vec_[k] += other[k+1];\n            }\n            //for( unsigned int k = 1; k <= dim_; k++ ) {\n            //    this->operator[](k) += other[k];\n            //}\n        }\n    \n    private:\n        unsigned int dim_;   // dimension of vector\n        double* vec_;        // entries of vector\n\n};\n\n// Modify driver a little bit\nint main() {\n\n    const unsigned int dim = 10;\n  \n    // set up 1st vector\n    VectorClass myVec( dim );\n    for( unsigned int idx = 1; idx <= dim; idx ++ ) {\n      myVec[ idx ] = static_cast<double>( dim - idx + 1 );\n    }\n    myVec.print( std::cout );\n    \n    // set up 2nd vector\n    VectorClass second( dim );\n    for( unsigned int idx = 1; idx <= dim; idx ++ ) {\n      second[ idx ] = static_cast<double>( idx );\n    }\n    second.print( std::cout );\n    \n    // add the 2nd to the 1st\n    myVec.add( second );\n    myVec.print();\n}","metadata":{"trusted":true},"execution_count":null,"outputs":[],"id":"cdfde2f9-fafc-4a9f-99b7-4952720e4521"},{"cell_type":"code","source":"!g++ -g VectorClass.cpp","metadata":{"trusted":true},"execution_count":null,"outputs":[],"id":"f9331dc3-19ff-44a2-a8f5-6e258f9266d2"},{"cell_type":"code","source":"!./a.out","metadata":{"trusted":true},"execution_count":null,"outputs":[],"id":"4f4d196d-761d-40e1-9d08-5df87307476b"},{"cell_type":"markdown","source":"**Note**: The adding itself seems to have worked correctly, but somehow we still have a problem. So what's wrong here?","metadata":{},"id":"3e04234e-4f33-44c4-9adb-0bde893019df"},{"cell_type":"markdown","source":"The answer to this is multifaceted:\n- Our implementation of *add()* used **call-by-copy**\n- Since we pass an object, its **copy constructor** is invoked\n- We haven't implemented one, but the compiler did automatically (thank's for that ;-)\n- Thus, the copy we get of **other** is a **flat** one!","metadata":{},"id":"7551ddc3-e449-47f1-bdc8-9a8080acdaf9"},{"cell_type":"markdown","source":"***\nWe can check on that by making the destructor tell us which block it is going to deallocate and run our code through valgrind:\n***\n**==> valgrind ./a.out**\n<div>\n==28488== Memcheck, a memory error detector</br>\n==28488== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.</br>\n==28488== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info</br>\n==28488== Command: ./a.out</br>\n==28488== </br>\nAn instance of VectorClass was generated. dim_ = 10</br>\n(10, 9, 8, 7, 6, 5, 4, 3, 2, 1)</br>\nAn instance of VectorClass was generated. dim_ = 10</br>\n(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)</br>\n<font color=\"red\">Going to delete memory starting at address 0x4d9b150</font></br>\nAn instance of VectorClass was destroyed and 80 bytes freed.</br>\n(11, 11, 11, 11, 11, 11, 11, 11, 11, 11)</br>\n<font color=\"red\">Going to delete memory starting at address 0x4d9b150</font></br>\n==28488== Invalid free() / delete / delete[] / realloc()</br>\n==28488==    at 0x483758B: operator delete[](void*) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)</br>\n==28488==    by 0x109500: VectorClass::~VectorClass() (VectorClass3.cpp:30)</br>\n==28488==    by 0x109341: main (VectorClass3.cpp:93)</br>\n==28488==  Address 0x4d9b150 is 0 bytes inside a block of size 80 free'd</br>\n==28488==    at 0x483758B: operator delete[](void*) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)</br>\n==28488==    by 0x109500: VectorClass::~VectorClass() (VectorClass3.cpp:30)</br>\n==28488==    by 0x109322: main (VectorClass3.cpp:100)</br>\n==28488==  Block was alloc'd at</br>\n==28488==    at 0x483650F: operator new[](unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)</br>\n==28488==    by 0x109450: VectorClass::VectorClass(unsigned int) (VectorClass3.cpp:15)</br>\n==28488==    by 0x109291: main (VectorClass3.cpp:93)</br>\n==28488== </br>\nAn instance of VectorClass was destroyed and 80 bytes freed.</br>\nGoing to delete memory starting at address 0x4d9ac80</br>\nAn instance of VectorClass was destroyed and 80 bytes freed.</br>\n==28488== </br>\n==28488== HEAP SUMMARY:</br>\n==28488==     in use at exit: 0 bytes in 0 blocks</br>\n==28488==   total heap usage: 4 allocs, 5 frees, 73,888 bytes allocated</br>\n==28488== </br>\n==28488== All heap blocks were freed -- no leaks are possible</br>\n==28488== </br>\n==28488== For counts of detected and suppressed errors, rerun with: -v</br>\n==28488== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)</br>\n</div>","metadata":{},"id":"02714f7e-52c4-4890-8a87-05ca91d651e5"},{"cell_type":"markdown","source":"Another way to check on this is to remove the automatic copy constructor","metadata":{},"id":"48d75c49-dd79-420e-9e00-c75865245b5c"},{"cell_type":"code","source":"%%file VectorClass.cpp\n\n#include <iostream>\n#include <cassert>\n\nclass VectorClass{\n    \n    public:\n    \n        // User should specify dimension at object creation\n        VectorClass( unsigned int dim ) : dim_(dim) {\n            \n            // don't allow vectors with zero dimension\n            assert( dim_ > 0 );\n\n            // allocate memory (will throw an exception, if it fails)\n            vec_ = new double[ dim_ ];\n            \n            // be talkative ;-)\n            std::cout << \"An instance of VectorClass was generated. dim_ = \" << dim_ << std::endl;\n        }\n\n        // Don't allow the default constructor [prior to C++11 you would solve this by making it private]\n        VectorClass() = delete;\n\n        // Don't allow the following default copy constructor either\n        VectorClass( VectorClass &other ) = delete;\n    \n        // We need to implement a destructor to free the dynamic memory again, otherwise we easily produce\n        // memory leaks\n        ~VectorClass() {\n            delete[] vec_;\n            std::cout << \"An instance of VectorClass was destroyed and \" << dim_ * sizeof(double)\n                      << \" bytes freed.\" << std::endl;\n        }\n\n        // provide access to the vector's dimension\n        unsigned int getDim() { return dim_; }\n    \n        // overload the [] for accessing individual entries\n        double& operator[] ( unsigned int index ){\n            assert( index != 0 && index <= dim_ );\n            return vec_[index-1];\n        }\n\n        // pretty print vector to given output stream (default will be std::cout)\n        void print( std::ostream &os = std::cout ) {\n            os << \"(\";\n            for( unsigned int k = 0; k < dim_-1; k++ ) {\n                os << vec_[k] << \", \";\n            }\n            os << vec_[dim_-1] << \")\" << std::endl;\n        }\n    \n        // scale vector with a constant\n        void scale( double factor ) {\n            // leave that to students\n        }\n    \n        // add to vectors together (that's actually a little bit tricky, due to the question \"where to put the result?\"\n        // for the moment leave it with adding another vector to the one on which the method is called.\n    \n        // let us try the following, and determine, why it will fail ;-)\n        void add( VectorClass other ) {\n\n            // make sure that input vector has correct length\n            assert( other.getDim() == dim_ );\n            // for( unsigned int k = 0; k < dim_; k++ ) {\n            //     vec_[k] += other[k+1];\n            // }\n            for( unsigned int k = 1; k <= dim_; k++ ) {\n                this->operator[](k) += other[k];\n            }\n        }\n    \n    private:\n        unsigned int dim_;   // dimension of vector\n        double* vec_;        // entries of vector\n\n};\n\n// Modify driver a little bit\nint main() {\n\n    const unsigned int dim = 10;\n  \n    // set up 1st vector\n    VectorClass myVec( dim );\n    for( unsigned int idx = 1; idx <= dim; idx ++ ) {\n      myVec[ idx ] = static_cast<double>( dim - idx + 1 );\n    }\n    myVec.print( std::cout );\n    \n    // set up 2nd vector\n    VectorClass other( dim );\n    for( unsigned int idx = 1; idx <= dim; idx ++ ) {\n      other[ idx ] = static_cast<double>( idx );\n    }\n    other.print( std::cout );\n    \n    // add the 2nd to the 1st\n    myVec.add( other );\n    myVec.print();\n}","metadata":{"trusted":true},"execution_count":null,"outputs":[],"id":"def80c0f-89b6-4e00-995a-14b8e800975c"},{"cell_type":"code","source":"!g++ VectorClass.cpp","metadata":{"trusted":true},"execution_count":null,"outputs":[],"id":"473de9eb-b04c-4087-8444-8d4b3c4c9fb8"},{"cell_type":"markdown","source":"#### Solution?\nHow should we resolve the issue?\n***\nFor the current case the best solution is to change the interface of our `add()` method to be\n\n`void add( const VectorClass& other )`\n\nThe `const` is no must, but makes it clear to other programmers and the compiler that we are not going to change the object\nother inside add().","metadata":{},"id":"91724843-2e97-4862-888a-291fda71444a"},{"cell_type":"code","source":"#include <iostream>\n#include <cassert>\n\nclass VectorClass{\n    \n    public:\n    \n        // User should specify dimension at object creation\n        VectorClass( unsigned int dim ) : dim_(dim) {\n            \n            // don't allow vectors with zero dimension\n            assert( dim_ > 0 );\n\n            // allocate memory (will throw an exception, if it fails)\n            vec_ = new double[ dim_ ];\n            \n            // be talkative ;-)\n            std::cout << \"An instance of VectorClass was generated. dim_ = \" << dim_ << std::endl;\n        }\n\n        // Don't allow the default constructor [prior to C++11 you would solve this by making it private]\n        VectorClass() = delete;\n\n        // Don't allow the following default copy constructor either\n        VectorClass( VectorClass &other ) = delete;\n    \n        // We need to implement a destructor to free the dynamic memory again, otherwise we easily produce\n        // memory leaks\n        ~VectorClass() {\n            delete[] vec_;\n            std::cout << \"An instance of VectorClass was destroyed and \" << dim_ * sizeof(double)\n                      << \" bytes freed.\" << std::endl;\n        }\n\n        // provide access to the vector's dimension\n        unsigned int getDim() { return dim_; }\n    \n        // overload the [] for accessing individual entries\n        double& operator[] ( unsigned int index ){\n            assert( index != 0 && index <= dim_ );\n            return vec_[index-1];\n        }\n\n        // pretty print vector to given output stream (default will be std::cout)\n        void print( std::ostream &os = std::cout ) {\n            os << \"(\";\n            for( unsigned int k = 0; k < dim_-1; k++ ) {\n                os << vec_[k] << \", \";\n            }\n            os << vec_[dim_-1] << \")\" << std::endl;\n        }\n    \n        // scale vector with a constant\n        void scale( double factor ) {\n            // leave that to students\n        }\n    \n        // add to vectors together (that's actually a little bit tricky, due to the question \"where to put the result?\"\n        // for the moment leave it with adding another vector to the one on which the method is called.\n    \n        // let us try the following, and determine, why it will fail ;-)\n        void add( const VectorClass& other ) {\n\n            // make sure that input vector has correct length\n            assert( other.getDim() == dim_ );\n            // for( unsigned int k = 0; k < dim_; k++ ) {\n            //     vec_[k] += other[k+1];\n            // }\n            for( unsigned int k = 1; k <= dim_; k++ ) {\n                this->operator[](k) += other[k];\n            }\n        }\n    \n    private:\n        unsigned int dim_;   // dimension of vector\n        double* vec_;        // entries of vector\n\n};\n\n// Modify driver a little bit\nint main() {\n\n    const unsigned int dim = 10;\n  \n    // set up 1st vector\n    VectorClass myVec( dim );\n    for( unsigned int idx = 1; idx <= dim; idx ++ ) {\n      myVec[ idx ] = static_cast<double>( dim - idx + 1 );\n    }\n    myVec.print( std::cout );\n    \n    // set up 2nd vector\n    VectorClass other( dim );\n    for( unsigned int idx = 1; idx <= dim; idx ++ ) {\n      other[ idx ] = static_cast<double>( idx );\n    }\n    other.print( std::cout );\n    \n    // add the 2nd to the 1st\n    myVec.add( other );\n    myVec.print();\n}","metadata":{"trusted":true},"execution_count":null,"outputs":[],"id":"30eccd22-8c5e-4062-a1d1-8006981aae99"},{"cell_type":"markdown","source":"***\nAh, okay. So the `const` was a good idea, but requires a little bit of extra work!\n\nWe need to implement a second version of the operator overloading that returns a const reference!","metadata":{},"id":"a6bfec6d-9eba-4e34-9ec8-e74bfa485664"},{"cell_type":"code","source":"#include <iostream>\n#include <cassert>\n\nclass VectorClass{\n    \n    public:\n    \n        // User should specify dimension at object creation\n        VectorClass( unsigned int dim ) : dim_(dim) {\n            \n            // don't allow vectors with zero dimension\n            assert( dim_ > 0 );\n\n            // allocate memory (will throw an exception, if it fails)\n            vec_ = new double[ dim_ ];\n            \n            // be talkative ;-)\n            std::cout << \"An instance of VectorClass was generated. dim_ = \" << dim_ << std::endl;\n        }\n\n        // Don't allow the default constructor [prior to C++11 you would solve this by making it private]\n        VectorClass() = delete;\n\n        // Don't allow the following default copy constructor either\n        VectorClass( VectorClass &other ) = delete;\n    \n        // We need to implement a destructor to free the dynamic memory again, otherwise we easily produce\n        // memory leaks\n        ~VectorClass() {\n            delete[] vec_;\n            std::cout << \"An instance of VectorClass was destroyed and \" << dim_ * sizeof(double)\n                      << \" bytes freed.\" << std::endl;\n        }\n\n        // provide access to the vector's dimension\n        unsigned int getDim() { return dim_; }\n    \n        // overload the [] for accessing individual entries\n        double& operator[] ( unsigned int index ){\n            assert( index != 0 && index <= dim_ );\n            return vec_[index-1];\n        }\n    \n        // overload the [] for accessing individual entries\n        const double& operator[] ( unsigned int index ) {\n            assert( index != 0 && index <= dim_ );\n            return vec_[index-1];\n        }\n    \n        // pretty print vector to given output stream (default will be std::cout)\n        void print( std::ostream &os = std::cout ) {\n            os << \"(\";\n            for( unsigned int k = 0; k < dim_-1; k++ ) {\n                os << vec_[k] << \", \";\n            }\n            os << vec_[dim_-1] << \")\" << std::endl;\n        }\n    \n        // scale vector with a constant\n        void scale( double factor ) {\n            // leave that to students\n        }\n    \n        // add to vectors together (that's actually a little bit tricky, due to the question \"where to put the result?\"\n        // for the moment leave it with adding another vector to the one on which the method is called.\n    \n        // let us try the following, and determine, why it will fail ;-)\n        void add( const VectorClass& other ) {\n\n            // make sure that input vector has correct length\n            assert( other.getDim() == dim_ );\n            // for( unsigned int k = 0; k < dim_; k++ ) {\n            //     vec_[k] += other[k+1];\n            // }\n            for( unsigned int k = 1; k <= dim_; k++ ) {\n                this->operator[](k) += other[k];\n            }\n        }\n    \n    private:\n        unsigned int dim_;   // dimension of vector\n        double* vec_;        // entries of vector\n\n};\n\n// Modify driver a little bit\nint main() {\n\n    const unsigned int dim = 10;\n  \n    // set up 1st vector\n    VectorClass myVec( dim );\n    for( unsigned int idx = 1; idx <= dim; idx ++ ) {\n      myVec[ idx ] = static_cast<double>( dim - idx + 1 );\n    }\n    myVec.print( std::cout );\n    \n    // set up 2nd vector\n    VectorClass other( dim );\n    for( unsigned int idx = 1; idx <= dim; idx ++ ) {\n      other[ idx ] = static_cast<double>( idx );\n    }\n    other.print( std::cout );\n    \n    // add the 2nd to the 1st\n    myVec.add( other );\n    myVec.print();\n}","metadata":{"trusted":true},"execution_count":null,"outputs":[],"id":"15b02a70-a496-4098-a446-9a60ee30b116"},{"cell_type":"markdown","source":"Shoot, we have a problem with the **signature** now!\n\nBut, fortunately, there is a way out of this:\n- We can tell the compiler that a member function does not alter its object! This will also be part of the signature. So we can implement our overloading as\n`const double& operator[] ( unsigned int index ) const`\n- We might want to do this also for any other member function that does not change the object, like e.g. `print()`\n\nIf we do this, we end up with the final version:","metadata":{},"id":"6a78d290-77dc-43a5-93f5-15fa2c650ddb"},{"cell_type":"code","source":"#include <iostream>\n#include <cassert>\n\nclass VectorClass {\n    \npublic:\n    \n  // User should specify dimension at object creation\n  VectorClass( unsigned int dim ) : dim_(dim) {\n            \n    // don't allow vectors with zero dimension\n    assert( dim_ > 0 );\n\n    // allocate memory (will throw an exception, if it fails)\n    vec_ = new double[ dim_ ];\n            \n    // be talkative ;-)\n    std::cout << \"An instance of VectorClass was generated. dim_ = \" \n              << dim_ << std::endl;\n  }\n\n  // Don't allow the default constructor\n  // [prior to C++11 you would solve this by making it private]\n  VectorClass() = delete;\n\n  // Don't allow the following default copy constructor either    \n  VectorClass( VectorClass &other ) = delete;\n \n  // We need to implement a destructor to free the dynamic memory again,\n  // otherwise we easily produce memory leaks\n  ~VectorClass() {\n    std::cout << \"Going to delete memory starting at address \"\n              << vec_ << std::endl;\n          \n    delete[] vec_;\n    std::cout << \"An instance of VectorClass was destroyed and \"\n              << dim_ * sizeof(double)\n              << \" bytes freed.\" << std::endl;\n  }\n\n  // provide access to the vector's dimension\n  unsigned int getDim() const { return dim_; }\n    \n  // overload the [] for accessing individual entries\n  double& operator[] ( unsigned int index ) {\n    assert( index != 0 && index <= dim_ );\n    return vec_[index-1];\n  }\n\n  const double& operator[] ( unsigned int index ) const {\n    assert( index != 0 && index <= dim_ );\n    return vec_[index-1];\n  }\n\n  // pretty print vector to given output stream (default will be std::cout)\n  void print( std::ostream &os = std::cout ) const {\n    os << \"(\";\n    for( unsigned int k = 0; k < dim_-1; k++ ) {\n      os << vec_[k] << \", \";\n    }\n    os << vec_[dim_-1] << \")\" << std::endl;\n  }\n    \n  // scale vector with a constant\n  void scale( double factor ) {\n    // leave that to students\n  }\n    \n  // add to vectors together (that's actually a little bit tricky,\n  // due to the question \"where to put the result?\"\n  // for the moment leave it with adding another vector to the one on which\n  // the method is called.\n  void add( const VectorClass& other ) {\n\n    // make sure that input vector has correct length\n    assert( other.getDim() == dim_ );\n    // for( unsigned int k = 0; k < dim_; k++ ) {\n    //     vec_[k] += other[k+1];\n    // }\n    for( unsigned int k = 1; k <= dim_; k++ ) {\n      this->operator[](k) += other[k];\n    }\n  }\n    \nprivate:\n  unsigned int dim_;   // dimension of vector\n  double* vec_;        // entries of vector\n\n};","metadata":{"trusted":true},"execution_count":null,"outputs":[],"id":"0b2a852d-2a07-4f2a-85d2-7833051474d7"},{"cell_type":"code","source":"int main() {\n\n    const unsigned int dim = 10;\n  \n    // set up 1st vector\n    VectorClass myVec( dim );\n    for( unsigned int idx = 1; idx <= dim; idx ++ ) {\n      myVec[ idx ] = static_cast<double>( dim - idx + 1 );\n    }\n    myVec.print( std::cout );\n    \n    // set up 2nd vector\n    VectorClass other( dim );\n    for( unsigned int idx = 1; idx <= dim; idx ++ ) {\n      other[ idx ] = static_cast<double>( idx );\n    }\n    other.print( std::cout );\n    \n    // add the 2nd to the 1st\n    myVec.add( other );\n    myVec.print();\n}","metadata":{"trusted":true},"execution_count":null,"outputs":[],"id":"81aeb13c-be8f-4e15-b7d7-acffb4a575eb"},{"cell_type":"code","source":"main();","metadata":{"trusted":true},"execution_count":null,"outputs":[],"id":"77177a38-424a-4558-8836-9c6f95bdd7c0"},{"cell_type":"markdown","source":"***\n#### Separating Implementation and Interface\n\n- Assume that we have the definition of a `class A` in one source file and want to use the class in another source file `B.cpp`.\n- For this the compiler needs to known at least that `class A` exists:  \n  This can be accomplished by a **forward declaration** of the form  `class A;`\n- However, if we also want to access data or function members of A, the compiler needs further info.\n- There are three possibilities:\n  1. Put the complete definition of A into a header file `A.hpp` and include that into the source file `B.cpp`\n  1. Split up the declaration of the member functions and their implementation into two parts. A file `A.hpp` with the class declaration and a file `A.cpp` with the implementation of the member functions.\n  1. Use a combination of both, e.g. to allow inlining of certain short methods.\n- Each of the approaches has pros and cons. So the decision depends on the concrete scenario.\n***\nBrief example on the splitting approach:","metadata":{},"id":"56fb8027-e846-451f-bcda-c28c6e805530"},{"cell_type":"code","source":"%%file splitA.hpp\n\n#include <string>\n\nclass A {\n\n  std::string name_;\n\n  public:\n  void setName( const char* name );\n  void printName();\n\n};","metadata":{"trusted":true},"execution_count":null,"outputs":[],"id":"867de208-5492-44c0-bf04-7ac9f868908f"},{"cell_type":"code","source":"%%file splitA.cpp\n\n// Necessary, because otherwise compiler does not know a class A and a member function setName exists\n#include \"splitA.hpp\"\n\n// Need to prefix the member function name with the class name\nvoid A::setName( const char* name ) {\n  name_ = name;\n}","metadata":{"trusted":true},"execution_count":null,"outputs":[],"id":"639efb26-6150-4cdf-aef4-b962ba86a6a3"},{"cell_type":"code","source":"%%file splitB.cpp\n\n#include \"splitA.hpp\"\n\nint main( void ) {\n\n  A obj;\n  obj.setName( \"An object\" );\n\n  // Note: We have not implemented A::printName();\n  //       However, if it is not used, that's not an issue.\n  // obj.printName();\n}","metadata":{"trusted":true},"execution_count":null,"outputs":[],"id":"3ed47b3b-3b45-4fc3-ab31-655915b41251"},{"cell_type":"code","source":"!g++ splitA.cpp splitB.cpp\n./a.out","metadata":{"trusted":true},"execution_count":null,"outputs":[],"id":"2c897fb0-b3a2-4617-8b92-79dbaaff6b8b"},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[],"id":"782da53e-ca04-42d3-a318-a1501b17b654"}]}
\ No newline at end of file
diff --git a/notebooks/06_STL_Sequence_Containers.ipynb b/notebooks/06_STL_Sequence_Containers.ipynb
index a1179e0f0166bb5bf66cb82130f60b3c5cf05313..42b59ef92f414acea0eac21560f8bd6c31f11ef6 100644
--- a/notebooks/06_STL_Sequence_Containers.ipynb
+++ b/notebooks/06_STL_Sequence_Containers.ipynb
@@ -1,1288 +1 @@
-{
- "cells": [
-  {
-   "cell_type": "markdown",
-   "id": "0921615f",
-   "metadata": {},
-   "source": [
-    "# Standard Template Library (STL)\n"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "eacfe313",
-   "metadata": {},
-   "source": [
-    "#### Executive Summary\n",
-    "* Since its inclusion in 1994 the STL forms an integral part of the **Standard C++ Library**.\n",
-    "* The STL is composed of three major components:\n",
-    "    1. Definition of several **container types** for data storage\n",
-    "    1. Access functions for those containers, especially so called **iterators**\n",
-    "    1. **Algorithms** for working with the containers.\n",
-    "* The following table lists the header files to include for different aspects of the STL\n",
-    "    \n",
-    "| STL containers      | Iterators, Functors, Algorithms |\n",
-    "| :------------------ | :------------------------------ |\n",
-    "| **```<deque>```**   | **```<iterator>```**            |\n",
-    "| **```<list>```**    | **```<algorithm>```**           |\n",
-    "| **```<map>```**     | **```<functional>```**          |\n",
-    "| **```<queue>```**   |                                 |\n",
-    "| **```<set>```**     |                                 |\n",
-    "| **```<stack>```**   |                                 |\n",
-    "| **```<vector>```**  |                                 |\n",
-    "\n",
-    "* As its name suggests the STL makes heavy use of *generic programming* based on **templates**."
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "e3d3641e",
-   "metadata": {},
-   "source": [
-    "#### Vector\n",
-    "* Probably the STL container most often used is **```std::vector```**.\n",
-    "* It provides an array data-structure that\n",
-    "  1. can grow and shrink dynamically at runtime\n",
-    "  2. provides classical index-based access\n",
-    "  3. allows dynamic bounds checking"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 2,
-   "id": "213d8360",
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "#include <vector>\n",
-    "#include <iostream>\n",
-    "#include <iomanip>      // required for setw() below\n",
-    "\n",
-    "int main() {\n",
-    "\n",
-    "    const int n = 5;\n",
-    "    \n",
-    "    std::vector< int > vec;     // need to tell compiler what we will\n",
-    "                                // store inside vec: < int > = template argument\n",
-    "    \n",
-    "    for( int k = 1; k <= n; ++k ) {\n",
-    "        vec.push_back( k*k );   // append new entries at the end\n",
-    "    }\n",
-    "\n",
-    "    for( int k = 1; k <= n; ++k ) {\n",
-    "        std::cout << \"Square of \" << k << \" is \" << std::setw(2)\n",
-    "                  << vec[k-1] << std::endl;    // this container allows standard 0-based subscript access\n",
-    "    }\n",
-    "}"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 3,
-   "id": "bd290a8a",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Square of 1 is  1\n",
-      "Square of 2 is  4\n",
-      "Square of 3 is  9\n",
-      "Square of 4 is 16\n",
-      "Square of 5 is 25\n"
-     ]
-    }
-   ],
-   "source": [
-    "main();"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "aa2f2d9d",
-   "metadata": {},
-   "source": [
-    "Of course we can also store data of other types in a vector."
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 4,
-   "id": "0bb0723b",
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "#include <string>\n",
-    "\n",
-    "int main() {\n",
-    "\n",
-    "    std::vector< double > dVec;\n",
-    "    dVec.push_back( 22.0 );\n",
-    "    dVec.push_back( -1.0 );\n",
-    "    \n",
-    "    std::vector< std::string > sVec;\n",
-    "    sVec.push_back( \"Helena\");\n",
-    "    sVec.push_back( \"Odysseus\" );\n",
-    "}"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "aca19e34",
-   "metadata": {},
-   "source": [
-    "So let's try an example with a **home-made class**. We make the con/destructor/s of our class a little talkative, to better understand what's happening."
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 3,
-   "id": "e5b2a349",
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "class Dummy {\n",
-    "\n",
-    "public:\n",
-    "\n",
-    "    Dummy() = delete;\n",
-    " \n",
-    "    Dummy( const std::string& name ) : name_(name) {\n",
-    "        std::cout << \"Object '\" << name_ << \"' was created\" << std::endl;\n",
-    "    }\n",
-    "    \n",
-    "    Dummy( const Dummy& other ) {\n",
-    "        name_ = other.getName() + \"_copy\";\n",
-    "        std::cout << \"Object '\" << name_ << \"' was created\" << std::endl;\n",
-    "    }\n",
-    "\n",
-    "    ~Dummy() {\n",
-    "        std::cout << \"Object '\" << name_ << \"' was destroyed\" << std::endl;\n",
-    "    }\n",
-    "\n",
-    "    const std::string& getName() const {\n",
-    "        return name_;\n",
-    "    }\n",
-    "\n",
-    "private:\n",
-    "    \n",
-    "  std::string name_;\n",
-    "\n",
-    "};"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 6,
-   "id": "bd331ee4",
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "int main() {\n",
-    "\n",
-    "  std::cout << \"-> Creating single objects\" << std::endl;\n",
-    "  Dummy obj1( \"one\" );\n",
-    "  Dummy obj2( \"two\" );\n",
-    "\n",
-    "  std::cout << \"\\n-> Putting objects in container\" << std::endl;\n",
-    "  std::vector< Dummy > vec;\n",
-    "  vec.push_back( obj1 );\n",
-    "  vec.push_back( obj2 );\n",
-    "\n",
-    "  std::cout << \"\\n-> Auto clean-up at program end\" << std::endl;\n",
-    "}"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 7,
-   "id": "a04654d2",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "-> Creating single objects\n",
-      "Object 'one' was created\n",
-      "Object 'two' was created\n",
-      "\n",
-      "-> Putting objects in container\n",
-      "Object 'one_copy' was created\n",
-      "Object 'two_copy' was created\n",
-      "Object 'one_copy_copy' was created\n",
-      "Object 'one_copy' was destroyed\n",
-      "\n",
-      "-> Auto clean-up at program end\n",
-      "Object 'one_copy_copy' was destroyed\n",
-      "Object 'two_copy' was destroyed\n",
-      "Object 'two' was destroyed\n",
-      "Object 'one' was destroyed\n"
-     ]
-    }
-   ],
-   "source": [
-    "main();"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "e9db8ff6",
-   "metadata": {},
-   "source": [
-    "**Observations:**\n",
-    "1. Apparently ```std::vector``` stores **copies** of the objects we append.\n",
-    "1. But why is a second copy of **one**, i.e. **one_copy_copy** created?"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 8,
-   "id": "5d4ba36f",
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    " // Suggestions anyone?\n",
-    "\n",
-    "\n"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "e36f2bb9",
-   "metadata": {},
-   "source": [
-    "This has to do with the fact that an ```std::vector``` can dynamically grow and shrink. Consequently it has two different important properties\n",
-    "\n",
-    "* size = number of elements currently stored inside the vector\n",
-    "* capacity = currently available slots to store entries inside the vector\n",
-    "\n",
-    "The capacity of the vector is managed dynamically. We can see this in the following experiment:"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 9,
-   "id": "261a8327",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "vec: length =  0, capacity =  0\n",
-      "vec: length =  1, capacity =  1\n",
-      "vec: length =  2, capacity =  2\n",
-      "vec: length =  3, capacity =  4\n",
-      "vec: length =  4, capacity =  4\n",
-      "vec: length =  5, capacity =  8\n",
-      "vec: length =  6, capacity =  8\n",
-      "vec: length =  7, capacity =  8\n",
-      "vec: length =  8, capacity =  8\n",
-      "vec: length =  9, capacity = 16\n",
-      "vec: length = 10, capacity = 16\n",
-      "vec: length = 11, capacity = 16\n",
-      "vec: length = 12, capacity = 16\n",
-      "vec: length = 13, capacity = 16\n",
-      "vec: length = 14, capacity = 16\n",
-      "vec: length = 15, capacity = 16\n",
-      "vec: length = 16, capacity = 16\n",
-      "vec: length = 17, capacity = 32\n",
-      "vec: length = 18, capacity = 32\n",
-      "vec: length = 19, capacity = 32\n",
-      "vec: length = 20, capacity = 32\n",
-      "vec: length = 21, capacity = 32\n",
-      "vec: length = 22, capacity = 32\n",
-      "vec: length = 23, capacity = 32\n",
-      "vec: length = 24, capacity = 32\n",
-      "vec: length = 25, capacity = 32\n",
-      "vec: length = 26, capacity = 32\n",
-      "vec: length = 27, capacity = 32\n",
-      "vec: length = 28, capacity = 32\n",
-      "vec: length = 29, capacity = 32\n",
-      "vec: length = 30, capacity = 32\n",
-      "vec: length = 31, capacity = 32\n",
-      "vec: length = 32, capacity = 32\n",
-      "vec: length = 33, capacity = 64\n"
-     ]
-    }
-   ],
-   "source": [
-    "#include <vector>\n",
-    "#include <iostream>\n",
-    "#include <iomanip>\n",
-    "\n",
-    "int main() {\n",
-    "\n",
-    "  std::vector< int > vec;\n",
-    "\n",
-    "  std::cout << \"vec: length = \" << std::setw(2) << vec.size()\n",
-    "            << \", capacity = \" << std::setw(2) << vec.capacity()\n",
-    "            << std::endl;\n",
-    "\n",
-    "  for( int k = 1; k <= 33; k++ ) {\n",
-    "    vec.push_back( k );\n",
-    "    std::cout << \"vec: length = \" << std::setw(2) << vec.size()\n",
-    "              << \", capacity = \" << std::setw(2) << vec.capacity()\n",
-    "              << std::endl;\n",
-    "  }\n",
-    "}\n",
-    "\n",
-    "main();"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "b9d88e30",
-   "metadata": {},
-   "source": [
-    "**What happens, when the capacity is exhausted and must be enlarged?**\n",
-    "\n",
-    "* ```std::vector<T>``` is basically a wrapper class around a dynamic array ``T* data``  \n",
-    "  *(we can actually access this via the data() member function, e.g. to interface with C or Fortran)* \n",
-    "* When the capacity is exhausted, but we want to add another entry three steps need to happen\n",
-    "  1. Dynamical allocation of a new internal data-array with a new larger capacity.\n",
-    "  1. **Copying** of all exisisting entries from the old data-array to the new one.  \n",
-    "     *[That's what gave us \"Object 'one_copy_copy' was created\" above]*\n",
-    "  1. Destruction of objects in old data-array and its de-allocation.  \n",
-    "     *[That's what gave us \"Object 'one_copy' was destroyed\" above]*\n",
-    "* Afterwards the new entry can be appended.\n",
-    "\n",
-    "**Performance issue**  \n",
-    "The memory management, but especially the copying constitutes a significant overhead, especially for large arrays.\n",
-    "When we already know what the maximal size of our vector will be, we can avoid this, by **reserving** a large enough\n",
-    "capacity."
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 10,
-   "id": "664eec8e",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "vec: length =  0, capacity = 100\n",
-      "vec: length =  1, capacity = 100\n",
-      "vec: length =  2, capacity = 100\n",
-      "vec: length =  3, capacity = 100\n",
-      "vec: length =  4, capacity = 100\n",
-      "vec: length =  5, capacity = 100\n",
-      "vec: length =  6, capacity = 100\n",
-      "vec: length =  7, capacity = 100\n",
-      "vec: length =  8, capacity = 100\n",
-      "vec: length =  9, capacity = 100\n",
-      "vec: length = 10, capacity = 100\n",
-      "vec: length = 11, capacity = 100\n",
-      "vec: length = 12, capacity = 100\n",
-      "vec: length = 13, capacity = 100\n",
-      "vec: length = 14, capacity = 100\n",
-      "vec: length = 15, capacity = 100\n",
-      "vec: length = 16, capacity = 100\n",
-      "vec: length = 17, capacity = 100\n",
-      "vec: length = 18, capacity = 100\n",
-      "vec: length = 19, capacity = 100\n",
-      "vec: length = 20, capacity = 100\n",
-      "vec: length = 21, capacity = 100\n",
-      "vec: length = 22, capacity = 100\n",
-      "vec: length = 23, capacity = 100\n",
-      "vec: length = 24, capacity = 100\n",
-      "vec: length = 25, capacity = 100\n",
-      "vec: length = 26, capacity = 100\n",
-      "vec: length = 27, capacity = 100\n",
-      "vec: length = 28, capacity = 100\n",
-      "vec: length = 29, capacity = 100\n",
-      "vec: length = 30, capacity = 100\n",
-      "vec: length = 31, capacity = 100\n",
-      "vec: length = 32, capacity = 100\n",
-      "vec: length = 33, capacity = 100\n"
-     ]
-    }
-   ],
-   "source": [
-    "#include <vector>\n",
-    "#include <iostream>\n",
-    "#include <iomanip>\n",
-    "\n",
-    "int main() {\n",
-    "\n",
-    "  std::vector< int > vec;\n",
-    "\n",
-    "  // make the vector allocate a data-array of sufficient length\n",
-    "  vec.reserve( 100 );\n",
-    "    \n",
-    "  std::cout << \"vec: length = \" << std::setw(2) << vec.size()\n",
-    "            << \", capacity = \" << std::setw(2) << vec.capacity()\n",
-    "            << std::endl;\n",
-    "\n",
-    "  for( int k = 1; k <= 33; k++ ) {\n",
-    "    vec.push_back( k );\n",
-    "    std::cout << \"vec: length = \" << std::setw(2) << vec.size()\n",
-    "              << \", capacity = \" << std::setw(2) << vec.capacity()\n",
-    "              << std::endl;\n",
-    "  }\n",
-    "}\n",
-    "\n",
-    "main();"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "2352d31e",
-   "metadata": {},
-   "source": [
-    "***\n",
-    "This will also work for our original example with the class Dummy:"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 20,
-   "id": "a5dffa46-65b8-477b-bbd8-a0ad0801d1fb",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "-> Creating single objects\n",
-      "Object 'one' was created\n",
-      "Object 'two' was created\n",
-      "\n",
-      "-> Putting objects in container\n",
-      "Object 'one_copy' was created\n",
-      "Object 'two_copy' was created\n",
-      "\n",
-      "-> Auto clean-up at program end\n",
-      "Object 'one_copy' was destroyed\n",
-      "Object 'two_copy' was destroyed\n",
-      "Object 'two' was destroyed\n",
-      "Object 'one' was destroyed\n"
-     ]
-    }
-   ],
-   "source": [
-    "int main() {\n",
-    "\n",
-    "  std::cout << \"-> Creating single objects\" << std::endl;\n",
-    "  Dummy obj1( \"one\" );\n",
-    "  Dummy obj2( \"two\" );\n",
-    "\n",
-    "  std::cout << \"\\n-> Putting objects in container\" << std::endl;\n",
-    "  std::vector< Dummy > vec;\n",
-    "  vec.reserve( 2 );\n",
-    "  vec.push_back( obj1 );\n",
-    "  vec.push_back( obj2 );\n",
-    "\n",
-    "  std::cout << \"\\n-> Auto clean-up at program end\" << std::endl;\n",
-    "}\n",
-    "\n",
-    "main();"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "41bf0d83",
-   "metadata": {},
-   "source": [
-    "**But:** Wouldn't it be nicer/easier to have the reservation be part of the instantiation? Let's check:"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 12,
-   "id": "351ace20",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "In file included from input_line_5:1:\n",
-      "In file included from /home/mohr/local/miniconda3/envs/cling/include/xeus/xinterpreter.hpp:15:\n",
-      "In file included from /home/mohr/local/miniconda3/envs/cling/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/include/c++/9.3.0/vector:65:\n",
-      "\u001b[1m/home/mohr/local/miniconda3/envs/cling/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/include/c++/9.3.0/bits/stl_construct.h:75:38: \u001b[0m\u001b[0;1;31merror: \u001b[0m\u001b[1mcall to deleted constructor of '__cling_N56::Dummy'\u001b[0m\n",
-      "    { ::new(static_cast<void*>(__p)) _T1(std::forward<_Args>(__args)...); }\n",
-      "\u001b[0;1;32m                                     ^\n",
-      "\u001b[0m\u001b[1m/home/mohr/local/miniconda3/envs/cling/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/include/c++/9.3.0/bits/stl_uninitialized.h:545:8: \u001b[0m\u001b[0;1;30mnote: \u001b[0min instantiation of function template specialization\n",
-      "      'std::_Construct<__cling_N56::Dummy>' requested here\u001b[0m\n",
-      "                std::_Construct(std::__addressof(*__cur));\n",
-      "\u001b[0;1;32m                     ^\n",
-      "\u001b[0m\u001b[1m/home/mohr/local/miniconda3/envs/cling/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/include/c++/9.3.0/bits/stl_uninitialized.h:601:2: \u001b[0m\u001b[0;1;30mnote: \u001b[0min instantiation of function template specialization\n",
-      "      'std::__uninitialized_default_n_1<false>::__uninit_default_n<__cling_N56::Dummy\n",
-      "      *, unsigned long>' requested here\u001b[0m\n",
-      "        __uninit_default_n(__first, __n);\n",
-      "\u001b[0;1;32m        ^\n",
-      "\u001b[0m\u001b[1m/home/mohr/local/miniconda3/envs/cling/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/include/c++/9.3.0/bits/stl_uninitialized.h:663:19: \u001b[0m\u001b[0;1;30mnote: \u001b[0min instantiation of function template specialization\n",
-      "      'std::__uninitialized_default_n<__cling_N56::Dummy *, unsigned long>'\n",
-      "      requested here\u001b[0m\n",
-      "    { return std::__uninitialized_default_n(__first, __n); }\n",
-      "\u001b[0;1;32m                  ^\n",
-      "\u001b[0m\u001b[1m/home/mohr/local/miniconda3/envs/cling/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/include/c++/9.3.0/bits/stl_vector.h:1603:9: \u001b[0m\u001b[0;1;30mnote: \u001b[0min instantiation of function template specialization\n",
-      "      'std::__uninitialized_default_n_a<__cling_N56::Dummy *, unsigned long,\n",
-      "      __cling_N56::Dummy>' requested here\u001b[0m\n",
-      "          std::__uninitialized_default_n_a(this->_M_impl._M_start, __n,\n",
-      "\u001b[0;1;32m               ^\n",
-      "\u001b[0m\u001b[1m/home/mohr/local/miniconda3/envs/cling/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/include/c++/9.3.0/bits/stl_vector.h:509:9: \u001b[0m\u001b[0;1;30mnote: \u001b[0min instantiation of member function 'std::vector<__cling_N56::Dummy,\n",
-      "      std::allocator<__cling_N56::Dummy> >::_M_default_initialize' requested\n",
-      "      here\u001b[0m\n",
-      "      { _M_default_initialize(__n); }\n",
-      "\u001b[0;1;32m        ^\n",
-      "\u001b[0m\u001b[1minput_line_22:2:23: \u001b[0m\u001b[0;1;30mnote: \u001b[0min instantiation of member function 'std::vector<__cling_N56::Dummy,\n",
-      "      std::allocator<__cling_N56::Dummy> >::vector' requested here\u001b[0m\n",
-      " std::vector< Dummy > vec( 2 );\n",
-      "\u001b[0;1;32m                      ^\n",
-      "\u001b[0m\u001b[1minput_line_13:3:5: \u001b[0m\u001b[0;1;30mnote: \u001b[0m'Dummy' has been explicitly marked deleted here\u001b[0m\n",
-      "    Dummy() = delete;\n",
-      "\u001b[0;1;32m    ^\n",
-      "\u001b[0m"
-     ]
-    },
-    {
-     "ename": "Interpreter Error",
-     "evalue": "",
-     "output_type": "error",
-     "traceback": [
-      "Interpreter Error: "
-     ]
-    }
-   ],
-   "source": [
-    "std::vector< Dummy > vec( 2 );"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "ec2de34b",
-   "metadata": {},
-   "source": [
-    "Problem is that this version of the ```std::vector<T>``` constructor will try to fill/initialise the vector with objects of type ```T``` using their default constructor."
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "d1cdc134",
-   "metadata": {},
-   "source": [
-    "Let us take a look at other ways to construct an std::vector:"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 21,
-   "id": "b3dfe338",
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "int main() {\n",
-    "\n",
-    "  std::cout << \"-> Creating single objects\" << std::endl;\n",
-    "  Dummy obj1( \"one\" );\n",
-    "  Dummy obj2( \"two\" );\n",
-    "\n",
-    "  std::cout << \"\\n-> Putting objects in container\" << std::endl;\n",
-    "  std::vector< Dummy > vec;\n",
-    "\n",
-    "  // Will fail, as we have no default constructor\n",
-    "  // std::vector< Dummy > vec2( 2 );\n",
-    "\n",
-    "  // vec.push_back( obj1 );\n",
-    "  // std::vector< Dummy > vec2( vec );           // -> construction by copying\n",
-    "  // std::vector< Dummy > vec2 = vec;            // -> construction by copying (but move semantics?)\n",
-    "  // std::vector< Dummy > vec2( 5, obj1 );       // -> vector with 5 copies of object one\n",
-    "  // std::vector< Dummy > vec2( {obj1, obj2 } ); // -> using initialiser list (but is a temporary generated here?)\n",
-    "  // std::vector< Dummy > vec2{obj1, obj2 };     // -> clearer version with initialiser list\n",
-    "\n",
-    "  vec.emplace_back( \"three\" );     // <- what will this do?\n",
-    "\n",
-    "  std::cout << \"\\n-> Auto clean-up at program end\" << std::endl;\n",
-    "\n",
-    "}"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 22,
-   "id": "ad928c13",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "-> Creating single objects\n",
-      "Object 'one' was created\n",
-      "Object 'two' was created\n",
-      "\n",
-      "-> Putting objects in container\n",
-      "Object 'three' was created\n",
-      "\n",
-      "-> Auto clean-up at program end\n",
-      "Object 'three' was destroyed\n",
-      "Object 'two' was destroyed\n",
-      "Object 'one' was destroyed\n"
-     ]
-    }
-   ],
-   "source": [
-    "main();"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "eebc1269",
-   "metadata": {},
-   "source": [
-    "* ```emplace()``` allows to **generate** a new entry at a specified place inside the vector, passing the given arguments to the entry's constructor.\n",
-    "* ```emplace_back()``` does the same, but **appends at the end**."
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "dc64b2c9",
-   "metadata": {},
-   "source": [
-    "***\n",
-    "We have already seen that we have read/write access to entries of our vector with the **```[ ]```** operator. Another alternative is the **```at()```** method.\n",
-    "\n",
-    "The difference is that **```at()```** will throw an exception, when we commit an out-of-bounds access error."
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 23,
-   "id": "7e537a6b",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Overwriting exception.cpp\n"
-     ]
-    }
-   ],
-   "source": [
-    "%%file exception.cpp\n",
-    "\n",
-    "#include <iostream>\n",
-    "#include <vector>\n",
-    "\n",
-    "int main() {\n",
-    "\n",
-    "  std::vector< double > vec( 10, 2.0 );\n",
-    "\n",
-    "#ifdef OUT_OF_BOUNDS\n",
-    "  for( int k = 0; k <= 10; ++k ) {\n",
-    "    std::cout << \"vec[ \" << k << \" ] = \" << vec[k] << std::endl;\n",
-    "  }\n",
-    "  std::cout << \"Too bad we reached this line :-(\" << std::endl;\n",
-    "#else\n",
-    "  for( int k = 0; k <= 10; ++k ) {\n",
-    "    std::cout << \"vec[ \" << k << \" ] = \" << vec.at( k )\n",
-    "      << std::endl;\n",
-    "  }\n",
-    "#endif\n",
-    "\n",
-    "}"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 24,
-   "id": "0513b187",
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "!g++ -Wall -DOUT_OF_BOUNDS exception.cpp"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 25,
-   "id": "af593caa",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "vec[ 0 ] = 2\n",
-      "vec[ 1 ] = 2\n",
-      "vec[ 2 ] = 2\n",
-      "vec[ 3 ] = 2\n",
-      "vec[ 4 ] = 2\n",
-      "vec[ 5 ] = 2\n",
-      "vec[ 6 ] = 2\n",
-      "vec[ 7 ] = 2\n",
-      "vec[ 8 ] = 2\n",
-      "vec[ 9 ] = 2\n",
-      "vec[ 10 ] = 0\n",
-      "Too bad we reached this line :-(\n"
-     ]
-    }
-   ],
-   "source": [
-    "!./a.out"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 26,
-   "id": "131dd4f5",
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "!g++ -Wall exception.cpp"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 27,
-   "id": "e6ce23bd",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "vec[ 0 ] = 2\n",
-      "vec[ 1 ] = 2\n",
-      "vec[ 2 ] = 2\n",
-      "vec[ 3 ] = 2\n",
-      "vec[ 4 ] = 2\n",
-      "vec[ 5 ] = 2\n",
-      "vec[ 6 ] = 2\n",
-      "vec[ 7 ] = 2\n",
-      "vec[ 8 ] = 2\n",
-      "vec[ 9 ] = 2\n",
-      "terminate called after throwing an instance of 'std::out_of_range'\n",
-      "  what():  vector::_M_range_check: __n (which is 10) >= this->size() (which is 10)\n",
-      "Aborted (core dumped)\n"
-     ]
-    }
-   ],
-   "source": [
-    "!./a.out"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "8e0987ec",
-   "metadata": {},
-   "source": [
-    "### Iterators and range-based access"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "80b33721",
-   "metadata": {},
-   "source": [
-    "Our **std::vector** belongs to the class of sequence containers, i.e. the ordering of entries $e_k$ is important\n",
-    "\n",
-    "$$ \\Big( e_1, e_2, \\ldots, e_n \\Big)$$\n",
-    "\n",
-    "and the same value $v$ can show up at multiple positions ($e_i = v = e_j$ with $i\\neq j$).\n",
-    "\n",
-    "Another type of sequence container is the **linked list**. The **std::list** implements a doubly-linked list, i.e. each entry/element is composed of three parts\n",
-    "\n",
-    "$$ \\text{entry} = \\Big( \\text{payload}, \\text{prev}, \\text{next} \\Big)$$\n",
-    "\n",
-    "where\n",
-    " * payload = value of the entry\n",
-    " * prev = information on where to find the predecessor of this entry\n",
-    " * next = information on where to find the successor of this entry\n",
-    " \n",
-    "Contrary to a vector, a list does not offer index-based access to its elements. Instead we can do list-traversal.\n",
-    "\n",
-    "Now consider the following piece of code:"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 28,
-   "id": "eee3b34a",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "box(0) = 1\n",
-      "box(1) = 3\n",
-      "box(2) = 5\n",
-      "box(3) = 7\n",
-      "box(4) = 9\n"
-     ]
-    }
-   ],
-   "source": [
-    "#include <iostream>\n",
-    "#include <vector>\n",
-    "\n",
-    "int main() {\n",
-    "    using Container = std::vector< int >;\n",
-    "    Container box;\n",
-    "\n",
-    "    const int n = 5;\n",
-    "    \n",
-    "    // fill the box with odd numbers\n",
-    "    for( int k = 0; k < n; k++ ) {\n",
-    "        box.push_back( 2*k+1 );\n",
-    "    }\n",
-    "    \n",
-    "    // print its contents\n",
-    "    for( int k = 0; k < n; k++ ) {\n",
-    "        std::cout << \"box(\" << k << \") = \" << box[k] << std::endl;\n",
-    "    }\n",
-    "}\n",
-    "\n",
-    "main();"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "33c83653",
-   "metadata": {},
-   "source": [
-    "For what we are doing in the program the type of underlying container does not really matter.  \n",
-    "How about replacing vector with list for a change?"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 29,
-   "id": "d2806a4f",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "\u001b[1minput_line_33:13:50: \u001b[0m\u001b[0;1;31merror: \u001b[0m\u001b[1mtype 'Container' (aka 'list<int>') does not provide a subscript operator\u001b[0m\n",
-      "        std::cout << \"box(\" << k << \") = \" << box[k] << std::endl;\n",
-      "\u001b[0;1;32m                                              ~~~^~\n",
-      "\u001b[0m"
-     ]
-    },
-    {
-     "ename": "Interpreter Error",
-     "evalue": "",
-     "output_type": "error",
-     "traceback": [
-      "Interpreter Error: "
-     ]
-    }
-   ],
-   "source": [
-    "#include <iostream>\n",
-    "#include <list>      // okay, need to adapt the include\n",
-    "\n",
-    "int main() {\n",
-    "    using Container = std::list< int >;  // need to alter this statement\n",
-    "    Container box;\n",
-    "\n",
-    "    const int n = 5;\n",
-    "    \n",
-    "    // fill the box with odd numbers\n",
-    "    for( int k = 0; k < n; k++ ) {\n",
-    "        box.push_back( 2*k+1 );\n",
-    "    }\n",
-    "    \n",
-    "    // print its contents\n",
-    "    for( int k = 0; k < n; k++ ) {\n",
-    "        std::cout << \"box(\" << k << \") = \" << box[k] << std::endl;\n",
-    "    }\n",
-    "}\n",
-    "\n",
-    "main();"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "40d19e9a",
-   "metadata": {},
-   "source": [
-    "***\n",
-    "Now that is, where **iterators** come into play. They abstract away the details of the underlying container."
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 31,
-   "id": "4a6ba619",
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "#include <iostream>\n",
-    "#include <vector>\n",
-    "\n",
-    "int main() {\n",
-    "    using Container = std::vector< int >;\n",
-    "    Container box;\n",
-    "\n",
-    "    const int n = 5;\n",
-    "    \n",
-    "    // fill the box with odd numbers\n",
-    "    for( int k = 0; k < n; k++ ) {\n",
-    "        box.push_back( 2*k+1 );\n",
-    "    }\n",
-    "    \n",
-    "    // use an iterator-based loop\n",
-    "    int k = 0;\n",
-    "    for( Container::iterator it = box.begin(); it != box.end(); it++ ) {\n",
-    "        std::cout << \"box(\" << k << \") = \" << *it << std::endl;\n",
-    "        k++;\n",
-    "    }\n",
-    "}"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 32,
-   "id": "907c51a5",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "box(0) = 1\n",
-      "box(1) = 3\n",
-      "box(2) = 5\n",
-      "box(3) = 7\n",
-      "box(4) = 9\n"
-     ]
-    }
-   ],
-   "source": [
-    "main();"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "5b9766a5",
-   "metadata": {},
-   "source": [
-    "**Remarks:**\n",
-    "* The iterator is no pointer, but 'feels' like one, as it overloads the dereferencing operator ```*```.\n",
-    "* ```box.begin()``` points to the first entry in the container.\n",
-    "* ```box.end()``` points **after** the last entry in the container. Thus, dereferencing it would be illegal.\n",
-    "* Do not test for ```it < box.end()```, but for (in)equality only."
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "ba14f11e",
-   "metadata": {},
-   "source": [
-    "Since our loop is using an iterator now, we can with two small modifications switch from a **std::vector** to a **std::list**."
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 33,
-   "id": "9f8daf26",
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "#include <iostream>\n",
-    "#include <list>       // mod #1\n",
-    "\n",
-    "int main() {\n",
-    "    using Container = std::list< int >;    // mod #2\n",
-    "    Container box;\n",
-    "\n",
-    "    const int n = 5;\n",
-    "    \n",
-    "    // fill the box with odd numbers\n",
-    "    for( int k = 0; k < n; k++ ) {\n",
-    "        box.push_back( 2*k+1 );\n",
-    "    }\n",
-    "    \n",
-    "    // use an iterator-based loop\n",
-    "    int k = 0;\n",
-    "    for( Container::iterator it = box.begin(); it != box.end(); it++ ) {\n",
-    "        std::cout << \"box(\" << k << \") = \" << *it << std::endl;\n",
-    "        k++;\n",
-    "    }\n",
-    "}"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 34,
-   "id": "53211059",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "box(0) = 1\n",
-      "box(1) = 3\n",
-      "box(2) = 5\n",
-      "box(3) = 7\n",
-      "box(4) = 9\n"
-     ]
-    }
-   ],
-   "source": [
-    "main();"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "44f9f4e2",
-   "metadata": {},
-   "source": [
-    "#### 'Reverse mode' \n",
-    "Up above we have used a forward iterator. However, we can also ask for a reverse iterator to go through the container from end to start (if the container supports it)."
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 35,
-   "id": "158950d1",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "3\n",
-      "2\n",
-      "1\n"
-     ]
-    }
-   ],
-   "source": [
-    "#include <iostream>\n",
-    "\n",
-    "std::vector< short > vec;\n",
-    "\n",
-    "vec.push_back( 1 );\n",
-    "vec.push_back( 2 );\n",
-    "vec.push_back( 3 );\n",
-    "\n",
-    "for( std::vector< short >::reverse_iterator it = vec.rbegin(); it != vec.rend(); it++ ) {\n",
-    "    std::cout << *it << std::endl;\n",
-    "}"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "96bed53d",
-   "metadata": {},
-   "source": [
-    "#### 'Const mode'\n",
-    "When we do not intend to change the element in the loop body, we can also employ a ```const_iterator```."
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 36,
-   "id": "44a9bf28",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "4\n",
-      "5\n",
-      "6\n"
-     ]
-    }
-   ],
-   "source": [
-    "std::list< double > lc;\n",
-    "using cIter = std::list< double >::const_iterator;\n",
-    "lc.push_back( 4.0 );\n",
-    "lc.push_back( 5.0 );\n",
-    "lc.push_back( 6.0 );\n",
-    "for( cIter it = lc.begin(); it != lc.end(); it++ ) {\n",
-    "  std::cout << *it << std::endl;\n",
-    "}"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "da22b078",
-   "metadata": {},
-   "source": [
-    "#### 'Free Functions'\n",
-    "C++ introduced free-function forms of ```begin()``` and ```end()``` which we can use alternatively to the member functions above:"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 47,
-   "id": "ceb3de09",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "4\n",
-      "5\n",
-      "6\n"
-     ]
-    }
-   ],
-   "source": [
-    "for( cIter it = begin( lc ), e = end( lc ); it != e; it++ ) {\n",
-    "  std::cout << *it << std::endl;\n",
-    "}"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "14632b71",
-   "metadata": {},
-   "source": [
-    "Why did we introduce ```e```? Is it necessary?"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "c731df99",
-   "metadata": {},
-   "source": [
-    "### Range-based access\n",
-    "C++ nowadays also supports an even simpler way to encode a loop over a container:"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 41,
-   "id": "2497a826",
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "#include <iostream>\n",
-    "#include <list>\n",
-    "\n",
-    "int main() {\n",
-    "    using Container = std::list< int >;\n",
-    "    Container box;\n",
-    "\n",
-    "    const int n = 5;\n",
-    "    \n",
-    "    // fill the box with odd numbers\n",
-    "    for( int k = 0; k < n; k++ ) {\n",
-    "        box.push_back( 2*k+1 );\n",
-    "    }\n",
-    "    \n",
-    "    // change that to even, using a range-based loop\n",
-    "    for( int& entry: box ) {\n",
-    "        entry -= 1;\n",
-    "    }\n",
-    "    \n",
-    "    // print using a range-based loop (in this case we can do w/o a ref)\n",
-    "    int k = 0;\n",
-    "    for( int value: box ) {\n",
-    "        std::cout << \"box(\" << k << \") = \" << value << std::endl;\n",
-    "        k++;\n",
-    "    }\n",
-    "}"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 42,
-   "id": "a8918a0e",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "box(0) = 0\n",
-      "box(1) = 2\n",
-      "box(2) = 4\n",
-      "box(3) = 6\n",
-      "box(4) = 8\n"
-     ]
-    }
-   ],
-   "source": [
-    "main();"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "f4d8fd5e",
-   "metadata": {},
-   "source": [
-    "Note that the last loop version involved a copy operation!"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 43,
-   "id": "d1c64b51",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "-> Put objects into container\n",
-      "Object 'one' was created\n",
-      "Object 'two' was created\n",
-      "\n",
-      "-> Run a loop\n",
-      "Object 'one_copy' was created\n",
-      "* one_copy\n",
-      "Object 'one_copy' was destroyed\n",
-      "Object 'two_copy' was created\n",
-      "* two_copy\n",
-      "Object 'two_copy' was destroyed\n"
-     ]
-    }
-   ],
-   "source": [
-    "std::cout << \"-> Put objects into container\" << std::endl;\n",
-    "std::vector< Dummy > vec;\n",
-    "vec.reserve(2);\n",
-    "vec.emplace_back( \"one\" );\n",
-    "vec.emplace_back( \"two\" );\n",
-    "\n",
-    "std::cout << \"\\n-> Run a loop\" << std::endl;\n",
-    "for( Dummy x: vec ) {\n",
-    "    std::cout << \"* \" << x.getName() << std::endl;\n",
-    "}"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "28b2e3fb",
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  }
- ],
- "metadata": {
-  "kernelspec": {
-   "display_name": "C++14",
-   "language": "C++14",
-   "name": "xcpp14"
-  },
-  "language_info": {
-   "codemirror_mode": "text/x-c++src",
-   "file_extension": ".cpp",
-   "mimetype": "text/x-c++src",
-   "name": "c++",
-   "version": "14"
-  }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
+{"metadata":{"orig_nbformat":4,"kernelspec":{"display_name":"C++14","language":"C++14","name":"xcpp14"},"language_info":{"codemirror_mode":"text/x-c++src","file_extension":".cpp","mimetype":"text/x-c++src","name":"c++","version":"14"}},"nbformat_minor":5,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# Standard Template Library (STL)\n","metadata":{},"id":"0921615f"},{"cell_type":"markdown","source":"#### Executive Summary\n* Since its inclusion in 1994 the STL forms an integral part of the **Standard C++ Library**.\n* The STL is composed of three major components:\n    1. Definition of several **container types** for data storage\n    1. Access functions for those containers, especially so called **iterators**\n    1. **Algorithms** for working with the containers.\n* The following table lists the header files to include for different aspects of the STL\n    \n| STL containers      | Iterators, Functors, Algorithms |\n| :------------------ | :------------------------------ |\n| **```<deque>```**   | **```<iterator>```**            |\n| **```<list>```**    | **```<algorithm>```**           |\n| **```<map>```**     | **```<functional>```**          |\n| **```<queue>```**   |                                 |\n| **```<set>```**     |                                 |\n| **```<stack>```**   |                                 |\n| **```<vector>```**  |                                 |\n\n* As its name suggests the STL makes heavy use of *generic programming* based on **templates**.","metadata":{},"id":"eacfe313"},{"cell_type":"markdown","source":"#### Vector\n* Probably the STL container most often used is **```std::vector```**.\n* It provides an array data-structure that\n  1. can grow and shrink dynamically at runtime\n  2. provides classical index-based access\n  3. allows dynamic bounds checking","metadata":{},"id":"e3d3641e"},{"cell_type":"code","source":"#include <vector>\n#include <iostream>\n#include <iomanip>      // required for setw() below\n\nint main() {\n\n    const int n = 5;\n    \n    std::vector< int > vec;     // need to tell compiler what we will\n                                // store inside vec: < int > = template argument\n    \n    for( int k = 1; k <= n; ++k ) {\n        vec.push_back( k*k );   // append new entries at the end\n    }\n\n    for( int k = 1; k <= n; ++k ) {\n        std::cout << \"Square of \" << k << \" is \" << std::setw(2)\n                  << vec[k-1] << std::endl;    // this container allows standard 0-based subscript access\n    }\n}","metadata":{"trusted":true},"execution_count":1,"outputs":[],"id":"213d8360"},{"cell_type":"code","source":"main();","metadata":{"trusted":true},"execution_count":2,"outputs":[{"name":"stdout","text":"Square of 1 is  1\nSquare of 2 is  4\nSquare of 3 is  9\nSquare of 4 is 16\nSquare of 5 is 25\n","output_type":"stream"}],"id":"bd290a8a"},{"cell_type":"markdown","source":"Of course we can also store data of other types in a vector.","metadata":{},"id":"aa2f2d9d"},{"cell_type":"code","source":"#include <string>\n\nint main() {\n\n    std::vector< double > dVec;\n    dVec.push_back( 22.0 );\n    dVec.push_back( -1.0 );\n    \n    std::vector< std::string > sVec;\n    sVec.push_back( \"Helena\");\n    sVec.push_back( \"Odysseus\" );\n}","metadata":{"trusted":true},"execution_count":3,"outputs":[],"id":"0bb0723b"},{"cell_type":"markdown","source":"So let's try an example with a **home-made class**. We make the con/destructor/s of our class a little talkative, to better understand what's happening.","metadata":{},"id":"aca19e34"},{"cell_type":"code","source":"class Dummy {\n\npublic:\n\n    Dummy() = delete;\n \n    Dummy( const std::string& name ) : name_(name) {\n        std::cout << \"Object '\" << name_ << \"' was created\" << std::endl;\n    }\n    \n    Dummy( const Dummy& other ) {\n        name_ = other.getName() + \"_copy\";\n        std::cout << \"Object '\" << name_ << \"' was created\" << std::endl;\n    }\n\n    ~Dummy() {\n        std::cout << \"Object '\" << name_ << \"' was destroyed\" << std::endl;\n    }\n\n    const std::string& getName() const {\n        return name_;\n    }\n\nprivate:\n    \n  std::string name_;\n\n};","metadata":{"trusted":true},"execution_count":4,"outputs":[],"id":"e5b2a349"},{"cell_type":"code","source":"int main() {\n\n  std::cout << \"-> Creating single objects\" << std::endl;\n  Dummy obj1( \"one\" );\n  Dummy obj2( \"two\" );\n\n  std::cout << \"\\n-> Putting objects in container\" << std::endl;\n  std::vector< Dummy > vec;\n  vec.push_back( obj1 );\n  vec.push_back( obj2 );\n\n  std::cout << \"\\n-> Auto clean-up at program end\" << std::endl;\n}","metadata":{"trusted":true},"execution_count":5,"outputs":[],"id":"bd331ee4"},{"cell_type":"code","source":"main();","metadata":{"trusted":true},"execution_count":6,"outputs":[{"name":"stdout","text":"-> Creating single objects\nObject 'one' was created\nObject 'two' was created\n\n-> Putting objects in container\nObject 'one_copy' was created\nObject 'two_copy' was created\nObject 'one_copy_copy' was created\nObject 'one_copy' was destroyed\n\n-> Auto clean-up at program end\nObject 'one_copy_copy' was destroyed\nObject 'two_copy' was destroyed\nObject 'two' was destroyed\nObject 'one' was destroyed\n","output_type":"stream"}],"id":"a04654d2"},{"cell_type":"markdown","source":"**Observations:**\n1. Apparently ```std::vector``` stores **copies** of the objects we append.\n1. But why is a second copy of **one**, i.e. **one_copy_copy** created?","metadata":{},"id":"e9db8ff6"},{"cell_type":"code","source":" // Suggestions anyone?\n\n\n","metadata":{"trusted":true},"execution_count":7,"outputs":[],"id":"5d4ba36f"},{"cell_type":"markdown","source":"This has to do with the fact that an ```std::vector``` can dynamically grow and shrink. Consequently it has two different important properties\n\n* size = number of elements currently stored inside the vector\n* capacity = currently available slots to store entries inside the vector\n\nThe capacity of the vector is managed dynamically. We can see this in the following experiment:","metadata":{},"id":"e36f2bb9"},{"cell_type":"code","source":"#include <vector>\n#include <iostream>\n#include <iomanip>\n\nint main() {\n\n  std::vector< int > vec;\n\n  std::cout << \"vec: length = \" << std::setw(2) << vec.size()\n            << \", capacity = \" << std::setw(2) << vec.capacity()\n            << std::endl;\n\n  for( int k = 1; k <= 33; k++ ) {\n    vec.push_back( k );\n    std::cout << \"vec: length = \" << std::setw(2) << vec.size()\n              << \", capacity = \" << std::setw(2) << vec.capacity()\n              << std::endl;\n  }\n}\n\nmain();","metadata":{"trusted":true},"execution_count":8,"outputs":[{"name":"stdout","text":"vec: length =  0, capacity =  0\nvec: length =  1, capacity =  1\nvec: length =  2, capacity =  2\nvec: length =  3, capacity =  4\nvec: length =  4, capacity =  4\nvec: length =  5, capacity =  8\nvec: length =  6, capacity =  8\nvec: length =  7, capacity =  8\nvec: length =  8, capacity =  8\nvec: length =  9, capacity = 16\nvec: length = 10, capacity = 16\nvec: length = 11, capacity = 16\nvec: length = 12, capacity = 16\nvec: length = 13, capacity = 16\nvec: length = 14, capacity = 16\nvec: length = 15, capacity = 16\nvec: length = 16, capacity = 16\nvec: length = 17, capacity = 32\nvec: length = 18, capacity = 32\nvec: length = 19, capacity = 32\nvec: length = 20, capacity = 32\nvec: length = 21, capacity = 32\nvec: length = 22, capacity = 32\nvec: length = 23, capacity = 32\nvec: length = 24, capacity = 32\nvec: length = 25, capacity = 32\nvec: length = 26, capacity = 32\nvec: length = 27, capacity = 32\nvec: length = 28, capacity = 32\nvec: length = 29, capacity = 32\nvec: length = 30, capacity = 32\nvec: length = 31, capacity = 32\nvec: length = 32, capacity = 32\nvec: length = 33, capacity = 64\n","output_type":"stream"}],"id":"261a8327"},{"cell_type":"markdown","source":"**What happens, when the capacity is exhausted and must be enlarged?**\n\n* ```std::vector<T>``` is basically a wrapper class around a dynamic array ``T* data``  \n  *(we can actually access this via the data() member function, e.g. to interface with C or Fortran)* \n* When the capacity is exhausted, but we want to add another entry three steps need to happen\n  1. Dynamical allocation of a new internal data-array with a new larger capacity.\n  1. **Copying** of all exisisting entries from the old data-array to the new one.  \n     *[That's what gave us \"Object 'one_copy_copy' was created\" above]*\n  1. Destruction of objects in old data-array and its de-allocation.  \n     *[That's what gave us \"Object 'one_copy' was destroyed\" above]*\n* Afterwards the new entry can be appended.\n\n**Performance issue**  \nThe memory management, but especially the copying constitutes a significant overhead, especially for large arrays.\nWhen we already know what the maximal size of our vector will be, we can avoid this, by **reserving** a large enough\ncapacity.","metadata":{},"id":"b9d88e30"},{"cell_type":"code","source":"#include <vector>\n#include <iostream>\n#include <iomanip>\n\nint main() {\n\n  std::vector< int > vec;\n\n  // make the vector allocate a data-array of sufficient length\n  vec.reserve( 100 );\n    \n  std::cout << \"vec: length = \" << std::setw(2) << vec.size()\n            << \", capacity = \" << std::setw(2) << vec.capacity()\n            << std::endl;\n\n  for( int k = 1; k <= 33; k++ ) {\n    vec.push_back( k );\n    std::cout << \"vec: length = \" << std::setw(2) << vec.size()\n              << \", capacity = \" << std::setw(2) << vec.capacity()\n              << std::endl;\n  }\n}\n\nmain();","metadata":{"trusted":true},"execution_count":9,"outputs":[{"name":"stdout","text":"vec: length =  0, capacity = 100\nvec: length =  1, capacity = 100\nvec: length =  2, capacity = 100\nvec: length =  3, capacity = 100\nvec: length =  4, capacity = 100\nvec: length =  5, capacity = 100\nvec: length =  6, capacity = 100\nvec: length =  7, capacity = 100\nvec: length =  8, capacity = 100\nvec: length =  9, capacity = 100\nvec: length = 10, capacity = 100\nvec: length = 11, capacity = 100\nvec: length = 12, capacity = 100\nvec: length = 13, capacity = 100\nvec: length = 14, capacity = 100\nvec: length = 15, capacity = 100\nvec: length = 16, capacity = 100\nvec: length = 17, capacity = 100\nvec: length = 18, capacity = 100\nvec: length = 19, capacity = 100\nvec: length = 20, capacity = 100\nvec: length = 21, capacity = 100\nvec: length = 22, capacity = 100\nvec: length = 23, capacity = 100\nvec: length = 24, capacity = 100\nvec: length = 25, capacity = 100\nvec: length = 26, capacity = 100\nvec: length = 27, capacity = 100\nvec: length = 28, capacity = 100\nvec: length = 29, capacity = 100\nvec: length = 30, capacity = 100\nvec: length = 31, capacity = 100\nvec: length = 32, capacity = 100\nvec: length = 33, capacity = 100\n","output_type":"stream"}],"id":"664eec8e"},{"cell_type":"markdown","source":"***\nThis will also work for our original example with the class Dummy:","metadata":{},"id":"2352d31e"},{"cell_type":"code","source":"int main() {\n\n  std::cout << \"-> Creating single objects\" << std::endl;\n  Dummy obj1( \"one\" );\n  Dummy obj2( \"two\" );\n\n  std::cout << \"\\n-> Putting objects in container\" << std::endl;\n  std::vector< Dummy > vec;\n  vec.reserve( 2 );\n  vec.push_back( obj1 );\n  vec.push_back( obj2 );\n\n  std::cout << \"\\n-> Auto clean-up at program end\" << std::endl;\n}\n\nmain();","metadata":{"trusted":true},"execution_count":10,"outputs":[{"name":"stdout","text":"-> Creating single objects\nObject 'one' was created\nObject 'two' was created\n\n-> Putting objects in container\nObject 'one_copy' was created\nObject 'two_copy' was created\n\n-> Auto clean-up at program end\nObject 'one_copy' was destroyed\nObject 'two_copy' was destroyed\nObject 'two' was destroyed\nObject 'one' was destroyed\n","output_type":"stream"}],"id":"a5dffa46-65b8-477b-bbd8-a0ad0801d1fb"},{"cell_type":"markdown","source":"**But:** Wouldn't it be nicer/easier to have the reservation be part of the instantiation? Let's check:","metadata":{},"id":"41bf0d83"},{"cell_type":"code","source":"std::vector< Dummy > vec( 2 );","metadata":{"trusted":true},"execution_count":11,"outputs":[{"name":"stderr","text":"In file included from input_line_5:1:\nIn file included from /srv/conda/envs/notebook/include/xeus/xinterpreter.hpp:15:\nIn file included from /srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/vector:65:\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/stl_construct.h:75:38: error: call to deleted constructor of '__cling_N55::Dummy'\n    { ::new(static_cast<void*>(__p)) _T1(std::forward<_Args>(__args)...); }\n                                     ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/stl_uninitialized.h:545:8: note: in instantiation of function template specialization 'std::_Construct<__cling_N55::Dummy>' requested here\n                std::_Construct(std::__addressof(*__cur));\n                     ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/stl_uninitialized.h:601:2: note: in instantiation of function template specialization 'std::__uninitialized_default_n_1<false>::__uninit_default_n<__cling_N55::Dummy *, unsigned long>' requested here\n        __uninit_default_n(__first, __n);\n        ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/stl_uninitialized.h:663:19: note: in instantiation of function template specialization 'std::__uninitialized_default_n<__cling_N55::Dummy *, unsigned long>' requested here\n    { return std::__uninitialized_default_n(__first, __n); }\n                  ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/stl_vector.h:1603:9: note: in instantiation of function template specialization 'std::__uninitialized_default_n_a<__cling_N55::Dummy *, unsigned long, __cling_N55::Dummy>' requested here\n          std::__uninitialized_default_n_a(this->_M_impl._M_start, __n,\n               ^\n/srv/conda/envs/notebook/bin/../lib/gcc/../../x86_64-conda-linux-gnu/include/c++/9.4.0/bits/stl_vector.h:509:9: note: in instantiation of member function 'std::vector<__cling_N55::Dummy, std::allocator<__cling_N55::Dummy> >::_M_default_initialize' requested here\n      { _M_default_initialize(__n); }\n        ^\ninput_line_21:2:23: note: in instantiation of member function 'std::vector<__cling_N55::Dummy, std::allocator<__cling_N55::Dummy> >::vector' requested here\n std::vector< Dummy > vec( 2 );\n                      ^\ninput_line_12:3:5: note: 'Dummy' has been explicitly marked deleted here\n    Dummy() = delete;\n    ^\n","output_type":"stream"},{"ename":"Interpreter Error","evalue":"","traceback":["Interpreter Error: "],"output_type":"error"}],"id":"351ace20"},{"cell_type":"markdown","source":"Problem is that this version of the ```std::vector<T>``` constructor will try to fill/initialise the vector with objects of type ```T``` using their default constructor.","metadata":{},"id":"ec2de34b"},{"cell_type":"markdown","source":"Let us take a look at other ways to construct an std::vector:","metadata":{},"id":"d1cdc134"},{"cell_type":"code","source":"int main() {\n\n  std::cout << \"-> Creating single objects\" << std::endl;\n  Dummy obj1( \"one\" );\n  Dummy obj2( \"two\" );\n\n  std::cout << \"\\n-> Putting objects in container\" << std::endl;\n  std::vector< Dummy > vec;\n\n  // Will fail, as we have no default constructor\n  // std::vector< Dummy > vec2( 2 );\n\n  vec.push_back( obj1 );\n  // std::vector< Dummy > vec2( vec );           // -> construction by copying\n  // std::vector< Dummy > vec2 = vec;            // -> construction by copying (but move semantics?)\n  // std::vector< Dummy > vec2( 5, obj1 );       // -> vector with 5 copies of object one\n  // std::vector< Dummy > vec2( {obj1, obj2} ); // -> using initialiser list (but is a temporary generated here?)\n  // std::vector< Dummy > vec2{obj1, obj2};     // -> clearer version with initialiser list\n\n  vec.emplace_back( \"three\" );     // <- what will this do?\n\n  std::cout << \"\\n-> Auto clean-up at program end\" << std::endl;\n\n}","metadata":{"trusted":true},"execution_count":12,"outputs":[],"id":"b3dfe338"},{"cell_type":"code","source":"main();","metadata":{"trusted":true},"execution_count":13,"outputs":[{"name":"stdout","text":"-> Creating single objects\nObject 'one' was created\nObject 'two' was created\n\n-> Putting objects in container\nObject 'one_copy' was created\nObject 'three' was created\nObject 'one_copy_copy' was created\nObject 'one_copy' was destroyed\n\n-> Auto clean-up at program end\nObject 'one_copy_copy' was destroyed\nObject 'three' was destroyed\nObject 'two' was destroyed\nObject 'one' was destroyed\n","output_type":"stream"}],"id":"ad928c13"},{"cell_type":"markdown","source":"* ```emplace()``` allows to **generate** a new entry at a specified place inside the vector, passing the given arguments to the entry's constructor.\n* ```emplace_back()``` does the same, but **appends at the end**.","metadata":{},"id":"eebc1269"},{"cell_type":"markdown","source":"***\nWe have already seen that we have read/write access to entries of our vector with the **```[ ]```** operator. Another alternative is the **```at()```** method.\n\nThe difference is that **```at()```** will throw an exception, when we commit an out-of-bounds access error.","metadata":{},"id":"dc64b2c9"},{"cell_type":"code","source":"%%file exception.cpp\n\n#include <iostream>\n#include <vector>\n\nint main() {\n\n  std::vector< double > vec( 10, 2.0 );\n\n#ifdef OUT_OF_BOUNDS\n  for( int k = 0; k <= 10; ++k ) {\n    std::cout << \"vec[ \" << k << \" ] = \" << vec[k] << std::endl;\n  }\n  std::cout << \"Too bad we reached this line :-(\" << std::endl;\n#else\n  for( int k = 0; k <= 10; ++k ) {\n    std::cout << \"vec[ \" << k << \" ] = \" << vec.at( k ) << std::endl;\n  }\n#endif\n\n}","metadata":{"trusted":true},"execution_count":14,"outputs":[{"name":"stdout","text":"Overwriting exception.cpp\n","output_type":"stream"}],"id":"7e537a6b"},{"cell_type":"code","source":"!g++ -Wall -DOUT_OF_BOUNDS exception.cpp","metadata":{"trusted":true},"execution_count":15,"outputs":[],"id":"0513b187"},{"cell_type":"code","source":"!./a.out","metadata":{"trusted":true},"execution_count":16,"outputs":[{"name":"stdout","text":"vec[ 0 ] = 2\nvec[ 1 ] = 2\nvec[ 2 ] = 2\nvec[ 3 ] = 2\nvec[ 4 ] = 2\nvec[ 5 ] = 2\nvec[ 6 ] = 2\nvec[ 7 ] = 2\nvec[ 8 ] = 2\nvec[ 9 ] = 2\nvec[ 10 ] = 0\nToo bad we reached this line :-(\n","output_type":"stream"}],"id":"af593caa"},{"cell_type":"code","source":"!g++ -Wall exception.cpp","metadata":{"trusted":true},"execution_count":17,"outputs":[],"id":"131dd4f5"},{"cell_type":"code","source":"!./a.out","metadata":{"trusted":true},"execution_count":18,"outputs":[{"name":"stdout","text":"vec[ 0 ] = 2\nvec[ 1 ] = 2\nvec[ 2 ] = 2\nvec[ 3 ] = 2\nvec[ 4 ] = 2\nvec[ 5 ] = 2\nvec[ 6 ] = 2\nvec[ 7 ] = 2\nvec[ 8 ] = 2\nvec[ 9 ] = 2\nterminate called after throwing an instance of 'std::out_of_range'\n  what():  vector::_M_range_check: __n (which is 10) >= this->size() (which is 10)\nAborted\n","output_type":"stream"}],"id":"e6ce23bd"},{"cell_type":"markdown","source":"### Iterators and range-based access","metadata":{},"id":"8e0987ec"},{"cell_type":"markdown","source":"Our **std::vector** belongs to the class of sequence containers, i.e. the ordering of entries $e_k$ is important\n\n$$ \\Big( e_1, e_2, \\ldots, e_n \\Big)$$\n\nand the same value $v$ can show up at multiple positions ($e_i = v = e_j$ with $i\\neq j$).\n\nAnother type of sequence container is the **linked list**. The **std::list** implements a doubly-linked list, i.e. each entry/element is composed of three parts\n\n$$ \\text{entry} = \\Big( \\text{payload}, \\text{prev}, \\text{next} \\Big)$$\n\nwhere\n * payload = value of the entry\n * prev = information on where to find the predecessor of this entry\n * next = information on where to find the successor of this entry\n \nContrary to a vector, a list does not offer index-based access to its elements. Instead we can do list-traversal.\n\nNow consider the following piece of code:","metadata":{},"id":"80b33721"},{"cell_type":"code","source":"#include <iostream>\n#include <vector>\n\nint main() {\n    using Container = std::vector< int >;\n    Container box;\n\n    const int n = 5;\n    \n    // fill the box with odd numbers\n    for( int k = 0; k < n; k++ ) {\n        box.push_back( 2*k+1 );\n    }\n    \n    // print its contents\n    for( int k = 0; k < n; k++ ) {\n        std::cout << \"box(\" << k << \") = \" << box[k] << std::endl;\n    }\n}\n\nmain();","metadata":{"trusted":true},"execution_count":19,"outputs":[{"name":"stdout","text":"box(0) = 1\nbox(1) = 3\nbox(2) = 5\nbox(3) = 7\nbox(4) = 9\n","output_type":"stream"}],"id":"eee3b34a"},{"cell_type":"markdown","source":"For what we are doing in the program the type of underlying container does not really matter.  \nHow about replacing vector with list for a change?","metadata":{},"id":"33c83653"},{"cell_type":"code","source":"#include <iostream>\n#include <list>      // okay, need to adapt the include\n\nint main() {\n    using Container = std::list< int >;  // need to alter this statement\n    Container box;\n\n    const int n = 5;\n    \n    // fill the box with odd numbers\n    for( int k = 0; k < n; k++ ) {\n        box.push_back( 2*k+1 );\n    }\n    \n    // print its contents\n    for( int k = 0; k < n; k++ ) {\n        std::cout << \"box(\" << k << \") = \" << box[k] << std::endl;\n    }\n}\n\nmain();","metadata":{"trusted":true},"execution_count":20,"outputs":[{"name":"stderr","text":"input_line_27:13:50: error: type 'Container' (aka 'list<int>') does not provide a subscript operator\n        std::cout << \"box(\" << k << \") = \" << box[k] << std::endl;\n                                              ~~~^~\n","output_type":"stream"},{"ename":"Interpreter Error","evalue":"","traceback":["Interpreter Error: "],"output_type":"error"}],"id":"d2806a4f"},{"cell_type":"markdown","source":"***\nNow that is, where **iterators** come into play. They abstract away the details of the underlying container.","metadata":{},"id":"40d19e9a"},{"cell_type":"code","source":"#include <iostream>\n#include <vector>\n\nint main() {\n    using Container = std::vector< int >;\n    Container box;\n\n    const int n = 5;\n    \n    // fill the box with odd numbers\n    for( int k = 0; k < n; k++ ) {\n        box.push_back( 2*k+1 );\n    }\n    \n    // use an iterator-based loop\n    int k = 0;\n    for( Container::iterator it = box.begin(); it != box.end(); it++ ) {\n        std::cout << \"box(\" << k << \") = \" << *it << std::endl;\n        k++;\n    }\n}","metadata":{"trusted":true},"execution_count":21,"outputs":[],"id":"4a6ba619"},{"cell_type":"code","source":"main();","metadata":{"trusted":true},"execution_count":22,"outputs":[{"name":"stdout","text":"box(0) = 1\nbox(1) = 3\nbox(2) = 5\nbox(3) = 7\nbox(4) = 9\n","output_type":"stream"}],"id":"907c51a5"},{"cell_type":"markdown","source":"**Remarks:**\n* The iterator is no pointer, but 'feels' like one, as it overloads the dereferencing operator ```*```.\n* ```box.begin()``` points to the first entry in the container.\n* ```box.end()``` points **after** the last entry in the container. Thus, dereferencing it would be illegal.\n* Do not test for ```it < box.end()```, but for (in)equality only.","metadata":{},"id":"5b9766a5"},{"cell_type":"markdown","source":"Since our loop is using an iterator now, we can with two small modifications switch from a **std::vector** to a **std::list**.","metadata":{},"id":"ba14f11e"},{"cell_type":"code","source":"#include <iostream>\n#include <list>       // mod #1\n\nint main() {\n    using Container = std::list< int >;    // mod #2\n    Container box;\n\n    const int n = 5;\n    \n    // fill the box with odd numbers\n    for( int k = 0; k < n; k++ ) {\n        box.push_back( 2*k+1 );\n    }\n    \n    // use an iterator-based loop\n    int k = 0;\n    for( Container::iterator it = box.begin(); it != box.end(); it++ ) {\n        std::cout << \"box(\" << k << \") = \" << *it << std::endl;\n        k++;\n    }\n}","metadata":{"trusted":true},"execution_count":23,"outputs":[],"id":"9f8daf26"},{"cell_type":"code","source":"main();","metadata":{"trusted":true},"execution_count":24,"outputs":[{"name":"stdout","text":"box(0) = 1\nbox(1) = 3\nbox(2) = 5\nbox(3) = 7\nbox(4) = 9\n","output_type":"stream"}],"id":"53211059"},{"cell_type":"markdown","source":"#### 'Reverse mode' \nUp above we have used a forward iterator. However, we can also ask for a reverse iterator to go through the container from end to start (if the container supports it).","metadata":{},"id":"44f9f4e2"},{"cell_type":"code","source":"#include <iostream>\n\nstd::vector< short > vec;\n\nvec.push_back( 1 );\nvec.push_back( 2 );\nvec.push_back( 3 );\n\nfor( std::vector< short >::reverse_iterator it = vec.rbegin(); it != vec.rend(); it++ ) {\n    std::cout << *it << std::endl;\n}","metadata":{"trusted":true},"execution_count":25,"outputs":[{"name":"stdout","text":"3\n2\n1\n","output_type":"stream"}],"id":"158950d1"},{"cell_type":"markdown","source":"#### 'Const mode'\nWhen we do not intend to change the element in the loop body, we can also employ a ```const_iterator```.","metadata":{},"id":"96bed53d"},{"cell_type":"code","source":"#include <iostream>\nstd::list< double > lc;\nusing cIter = std::list< double >::const_iterator;\nlc.push_back( 4.0 );\nlc.push_back( 5.0 );\nlc.push_back( 6.0 );\nfor( cIter it = lc.begin(); it != lc.end(); it++ ) {\n  std::cout << *it << std::endl;\n}","metadata":{"trusted":true},"execution_count":26,"outputs":[{"name":"stdout","text":"4\n5\n6\n","output_type":"stream"}],"id":"44a9bf28"},{"cell_type":"markdown","source":"#### 'Free Functions'\nC++ introduced free-function forms of ```begin()``` and ```end()``` which we can use alternatively to the member functions above:","metadata":{},"id":"da22b078"},{"cell_type":"code","source":"for( cIter it = begin( lc ), e = end( lc ); it != e; it++ ) {\n  std::cout << *it << std::endl;\n}","metadata":{"trusted":true},"execution_count":27,"outputs":[{"name":"stdout","text":"4\n5\n6\n","output_type":"stream"}],"id":"ceb3de09"},{"cell_type":"markdown","source":"Why did we introduce ```e```? Is it necessary?","metadata":{},"id":"14632b71"},{"cell_type":"markdown","source":"### Range-based access\nC++ nowadays also supports an even simpler way to encode a loop over a container:","metadata":{},"id":"c731df99"},{"cell_type":"code","source":"#include <iostream>\n#include <list>\n\nint main() {\n    using Container = std::list< int >;\n    Container box;\n\n    const int n = 5;\n    \n    // fill the box with odd numbers\n    for( int k = 0; k < n; k++ ) {\n        box.push_back( 2*k+1 );\n    }\n    \n    // change that to even, using a range-based loop\n    for( int& entry: box ) {\n        entry -= 1;\n    }\n    \n    // print using a range-based loop (in this case we can do w/o a ref)\n    int k = 0;\n    for( int value: box ) {\n        std::cout << \"box(\" << k << \") = \" << value << std::endl;\n        k++;\n    }\n}","metadata":{"trusted":true},"execution_count":28,"outputs":[],"id":"2497a826"},{"cell_type":"code","source":"main();","metadata":{"trusted":true},"execution_count":29,"outputs":[{"name":"stdout","text":"box(0) = 0\nbox(1) = 2\nbox(2) = 4\nbox(3) = 6\nbox(4) = 8\n","output_type":"stream"}],"id":"a8918a0e"},{"cell_type":"markdown","source":"Note that the last loop version involved a copy operation!","metadata":{},"id":"f4d8fd5e"},{"cell_type":"code","source":"std::cout << \"-> Put objects into container\" << std::endl;\nstd::vector< Dummy > vec;\nvec.reserve(2);\nvec.emplace_back( \"one\" );\nvec.emplace_back( \"two\" );\n\nstd::cout << \"\\n-> Run a loop\" << std::endl;\nfor( Dummy x: vec ) {\n    std::cout << \"* \" << x.getName() << std::endl;\n}","metadata":{"trusted":true},"execution_count":30,"outputs":[{"name":"stdout","text":"-> Put objects into container\nObject 'one' was created\nObject 'two' was created\n\n-> Run a loop\nObject 'one_copy' was created\n* one_copy\nObject 'one_copy' was destroyed\nObject 'two_copy' was created\n* two_copy\nObject 'two_copy' was destroyed\n","output_type":"stream"}],"id":"d1c64b51"},{"cell_type":"markdown","source":"Now let's try the same, but use a reference","metadata":{},"id":"eaf4c60a-ce19-410a-a81e-163d292de58d"},{"cell_type":"code","source":"std::cout << \"-> Put objects into container\" << std::endl;\nstd::vector< Dummy > vec;\nvec.reserve(2);\nvec.emplace_back( \"one\" );\nvec.emplace_back( \"two\" );\n\nstd::cout << \"\\n-> Run a loop\" << std::endl;\nfor( Dummy& x: vec ) {\n    std::cout << \"* \" << x.getName() << std::endl;\n}","metadata":{"trusted":true},"execution_count":31,"outputs":[{"name":"stdout","text":"-> Put objects into container\nObject 'one' was created\nObject 'two' was created\n\n-> Run a loop\n* one\n* two\n","output_type":"stream"}],"id":"28b2e3fb"},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[],"id":"c4afab4e-a800-4176-a26f-15d11ffd3964"}]}
\ No newline at end of file
diff --git a/notebooks/Task#1.ipynb b/notebooks/Task#1.ipynb
index 8b90ba59df9a2b7df6502b58e5bafc0f937832c6..362373347f9e6d828c95dbbc55a87fda1e49c358 100644
--- a/notebooks/Task#1.ipynb
+++ b/notebooks/Task#1.ipynb
@@ -1 +1 @@
-{"metadata":{"orig_nbformat":4,"language_info":{"codemirror_mode":"text/x-c++src","file_extension":".cpp","mimetype":"text/x-c++src","name":"c++","version":"17"},"kernelspec":{"name":"xcpp17","display_name":"C++17","language":"C++17"}},"nbformat_minor":5,"nbformat":4,"cells":[{"cell_type":"markdown","source":"### Task #1\n\nIn this task we want to further extend our ```VectorClass``` class. Specifically we would like add two methods and answer a question concerning ```VectorClass::print()```: \n 1. Implement missing body of VectorClass::scale()\n 1. Implement VectorClass::innerProduct(), how should the header look like?\n 1. What happens, when we call myVec.print() without arguments in main?","metadata":{},"id":"5b54f8c4-59a0-4a5a-a15c-021d20ae3d22"},{"cell_type":"markdown","source":"Let us start with (2). How should the interface for ```innerProduct()``` look like?","metadata":{},"id":"45df3877-fe76-43fd-afeb-dd4de9d969c3"},{"cell_type":"code","source":"// Your suggestions?\n\n","metadata":{},"execution_count":null,"outputs":[],"id":"a217056c-feec-46b7-aaac-5d673e57c53f"},{"cell_type":"markdown","source":"- Our vectors store entries of type ```double```. Thus, that would be a fitting return type for the value of the computed Euclidean inner product. *We could hand the result back via a parameter, too. But that is probably less convenient here.*\n- We need two vectors for the operation, so the second one should be an input argument. But:\n  - Use a reference to avoid copy generation.\n  - Not going to change the vector, so that could be const.\n- Method will not change the VectorClass object itself either, so the method could be marked const, too.\n\nSo we end up with:\n\n**``` double innerProduct( const VectorClass& second ) const;```**","metadata":{},"id":"0c933e9f-554b-455c-b023-7f8e533e75dd"},{"cell_type":"markdown","source":"***\nOkay, so below is our extended ```VectorClass``` minus the actual implementation of the two methods:","metadata":{},"id":"274868db-03d2-4c69-99e2-cbedc0f31960"},{"cell_type":"code","source":"#include <iostream>\n#include <cassert>\n\nclass VectorClass{\n    \npublic:\n\n  // ------------------------------------------------\n  // User should specify dimension at object creation\n  // ------------------------------------------------\n  VectorClass( unsigned int dim ) : dim_(dim) {\n            \n    // don't allow vectors with zero dimension\n    assert( dim_ > 0 );\n\n    // allocate memory (will throw an exception, if it fails)\n    vec_ = new double[ dim_ ];\n            \n    // be talkative ;-)\n    std::cout << \"An instance of VectorClass was generated. dim_ = \" << dim_ << std::endl;\n  }\n\n  // ----------------------------------------------------------\n  // Don't allow the default constructor\n  // [prior to C++11 you would solve this by making it private]\n  // ----------------------------------------------------------\n  VectorClass() = delete;\n\n  // ----------------------------------------------------------\n  // Don't allow the following default copy constructor either    \n  // ----------------------------------------------------------\n  VectorClass( VectorClass &other ) = delete;\n \n  // ----------------------------------------------------------\n  // We need to implement a destructor to free the dynamic memory again,\n  // otherwise we easily produce memory leaks\n  // ----------------------------------------------------------\n  ~VectorClass() {\n    std::cout << \"Going to delete memory starting at address \" << vec_ << std::endl;\n          \n    delete[] vec_;\n    std::cout << \"An instance of VectorClass was destroyed and \"\n              << dim_ * sizeof(double)\n              << \" bytes freed.\" << std::endl;\n  }\n\n  // ----------------------------------------------------------\n  // provide access to the vector's dimension\n  // ----------------------------------------------------------\n  unsigned int getDim() const { return dim_; }\n    \n  // ----------------------------------------------------------\n  // overload the [] for accessing individual entries\n  // ----------------------------------------------------------\n  double& operator[] ( unsigned int index ) {\n    assert( index != 0 && index <= dim_ );\n    return vec_[index-1];\n  }\n\n  const double& operator[] ( unsigned int index ) const {\n    assert( index != 0 && index <= dim_ );\n    return vec_[index-1];\n  }\n\n  // ----------------------------------------------------------------------\n  // pretty print vector to given output stream (default will be std::cout)\n  // ----------------------------------------------------------------------\n  void print( std::ostream &os = std::cout ) const {\n    os << \"(\";\n    for( unsigned int k = 0; k < dim_-1; k++ ) {\n      os << vec_[k] << \", \";\n    }\n    os << vec_[dim_-1] << \")\" << std::endl;\n  }\n    \n  // ----------------------------\n  // scale vector with a constant\n  // ----------------------------\n  void scale( double factor );\n    \n  // ----------------------------------------------\n  // compute Euclidean inner product of two vectors\n  // ----------------------------------------------\n  double innerProduct( const VectorClass& second ) const;\n    \n  // ----------------------------------------------------------------------\n  // add to vectors together (that's actually a little bit tricky,\n  // due to the question \"where to put the result?\"\n  // for the moment leave it with adding another vector to the one on which\n  // the method is called.\n  // ----------------------------------------------------------------------\n  void add( const VectorClass& other ) {\n\n    // make sure that input vector has correct length\n    assert( other.getDim() == dim_ );\n    // for( unsigned int k = 0; k < dim_; k++ ) {\n    //     vec_[k] += other[k+1];\n    // }\n    for( unsigned int k = 1; k <= dim_; k++ ) {\n      this->operator[](k) += other[k];\n    }\n  }\n    \nprivate:\n  unsigned int dim_;   // dimension of vector\n  double* vec_;        // entries of vector\n\n};","metadata":{"trusted":true},"execution_count":1,"outputs":[],"id":"2bcf89a4-e232-47f8-afe2-a88897f13a52"},{"cell_type":"markdown","source":"***\nNow let us implement ```scale()```","metadata":{},"id":"7ab16ac5-7f91-43cc-9a68-2e8a52dd3058"},{"cell_type":"code","source":"void VectorClass::scale( const double factor ) {\n \n    for( unsigned int k = 0; k < dim_; k++ ) {\n      vec_[k] *= factor;\n    }\n    \n}","metadata":{"trusted":true},"execution_count":2,"outputs":[],"id":"816a0c45-6ff9-4d67-97e7-b076bd23526d"},{"cell_type":"markdown","source":"and ```innerProduct()```","metadata":{},"id":"c84995ae-c03e-41e7-a060-f5d7b4382c55"},{"cell_type":"code","source":"double VectorClass::innerProduct( const VectorClass& second ) const {\n\n    double prod = 0.0;\n\n    for( unsigned int k = 0; k < dim_; k++ ) {\n      prod += vec_[k] * second[k+1];   // remember our overloading of [], vec_[k] = this->operator[k+1]\n    }\n\n    return prod;\n\n}   ","metadata":{"trusted":true},"execution_count":3,"outputs":[],"id":"139b925e-5b80-4ea8-80e9-ffb1ace29ffc"},{"cell_type":"markdown","source":"A question on ```scale()```: Why did we not make it **```void scale( const double factor ) const```** ?","metadata":{},"id":"0b36c822-eae1-4b20-b7ad-1ff1938b723c"},{"cell_type":"markdown","source":"\n\n\n\n\n\n\n\n\n\n\n\n\n","metadata":{},"id":"80b43239-51ec-4b63-af94-ce4e59fc6cc2"},{"cell_type":"markdown","source":"There are two aspects to this:\n1. The method itself cannot be marked ```const``` as it changes the state of our object, by changing values inside ```vec_```.\n1. We could mark ```factor``` as ```const```, but\n   - It is a local variable, so changes to factor would have no effect outside the body of scale() anyhow.\n   - For a basic datatype like double we are not sure if it would allow the compiler to perform some extra optimisations.\n   - Finally it is more a question of whether you think it is worth the extra effort of marking it this way.","metadata":{},"id":"9e17a14b-096c-4abb-b806-8fedc733c9fc"},{"cell_type":"markdown","source":"***\nBelow follows our test-driver that should run through now the extension was completed","metadata":{},"id":"b44bb8cd-35c0-45d5-8c0e-ee80fed8d018"},{"cell_type":"code","source":"#include <cmath>    // for using std::sqrt() below\n\nint main() {\n\n  const unsigned int dim = 10;\n  \n  // set up 1st vector\n  VectorClass myVec( dim );\n  for( unsigned int idx = 1u; idx <= dim; idx++ ) {\n    myVec[ idx ] = static_cast<double>( dim - idx + 1u );\n  }\n  myVec.print( std::cout );\n    \n  // set up 2nd vector\n  VectorClass other( dim );\n  for( unsigned int idx = 1u; idx <= dim; idx ++ ) {\n    other[ idx ] = static_cast<double>( idx );\n  }\n  other.print( std::cout );\n\n  // add the 2nd to the 1st\n  std::cout << \"\\nAdding both vectors gives: \";\n  myVec.add( other );\n  myVec.print();\n\n  // now scale second vector by 0.5\n  std::cout << \"\\nScaling the vector: \";\n  other.print();\n  std::cout << \"by 0.5 gives: \";\n  other.scale( 0.5 );\n  other.print();\n  std::cout << std::endl;\n\n  // compute the norm of the following vector\n  VectorClass vec( 2 );\n  vec[1] = 3.0;\n  vec[2] = -4.0;\n  double norm = vec.innerProduct( vec );\n  norm = std::sqrt( norm );\n  std::cout << \"Norm of vector \" << vec << \"is \" << norm << std::endl;\n  vec.print();\n  std::cout << \"is \" << norm << std::endl;\n    \n  std::cout << std::endl;\n  // now destructors will be called\n}","metadata":{"trusted":true},"execution_count":4,"outputs":[],"id":"6fd51fae-99a1-476c-ad9f-59529b88811e"},{"cell_type":"code","source":"main();","metadata":{"trusted":true},"execution_count":5,"outputs":[{"name":"stdout","text":"An instance of VectorClass was generated. dim_ = 10\n(10, 9, 8, 7, 6, 5, 4, 3, 2, 1)\nAn instance of VectorClass was generated. dim_ = 10\n(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)\n\nAdding both vectors gives: (11, 11, 11, 11, 11, 11, 11, 11, 11, 11)\n\nScaling the vector: (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)\nby 0.5 gives: (0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5)\n\nAn instance of VectorClass was generated. dim_ = 2\nNorm of vector (3, -4)\nis 5\n\nGoing to delete memory starting at address 0x55e6cfd4e580\nAn instance of VectorClass was destroyed and 16 bytes freed.\nGoing to delete memory starting at address 0x55e6d09bdf70\nAn instance of VectorClass was destroyed and 80 bytes freed.\nGoing to delete memory starting at address 0x55e6d07d8a60\nAn instance of VectorClass was destroyed and 80 bytes freed.\n","output_type":"stream"}],"id":"9c827691-afe9-4cfb-b71d-4f01bccd09c2"},{"cell_type":"markdown","source":"***\nFinally, we need to answer question (3).\n\n * In our driver we just called ```vec.print()``` without providing an output stream as argument. How did that work?\n\n * At some point we change the implementation of VectorClass::print() to have a **default value** for its os argument:  \n     **```void print( std::ostream &os = std::cout ) const```**\n     \n * Thus, if no argument is given, the compiler will automatically insert ```std::cout```.","metadata":{},"id":"067df258-3921-4328-bd14-cec60a4a02d8"},{"cell_type":"markdown","source":"#### Language Overview \n| language | optional arguments (w/ default values) | passing via keyword |\n|:---------| :-------------------------------------:|:-------------------:|\n| C        | no (only via workarounds)              | no                  |\n| C++      | yes                                    | no                  |\n| Fortran  | yes                                    | yes                 |\n| Python   | yes                                    | yes                 |\n\nPassing via keyword means, that we can set some arguments explicitely by a **name=value** pair.  \nPython example: ```print ('comma', 'separated', 'words', sep=', ')```  \n\n#### Optional Arguments in C++\n* In C++ there are some restrictions on the use of optional arguments.\n* Some of these are related to the fact that *passing via keyword* is not supported.\n* Rules are:\n  - optional arguments must follow the 'regular' ones\n  - if you do not supply a value for one optional argument, then you must also skip all arguments after that one","metadata":{},"id":"a59f1813-b205-439d-bb91-986e51df9336"},{"cell_type":"code","source":"#include <iostream>\n#include <string>\n\nvoid showVals( int a, int b = 2, double x = 1.0, std::string m = \"go\" ) {\n  std::cout << \"(\"\n            << a << \", \"\n            << b << \", \"\n            << x << \", \"\n            << m << \")\" << std::endl;\n}","metadata":{"trusted":true},"execution_count":7,"outputs":[],"id":"aa9570b3-2a56-4b23-acaa-48c28a781870"},{"cell_type":"code","source":"int main() {\n\n  showVals( 3 );\n  showVals( 5, 3 );\n  showVals( 1, 2, 3.0 );\n  showVals( 4, 5, 6, \"Alte Gags\" );\n\n  // showVals( 3, \"Polizei\" ); will not compile\n\n}\n\nmain();","metadata":{"trusted":true},"execution_count":11,"outputs":[{"name":"stdout","text":"(3, 2, 1, go)\n(5, 3, 1, go)\n(1, 2, 3, go)\n(4, 5, 6, Alte Gags)\n","output_type":"stream"}],"id":"ae9ceb03-fe74-4774-9d9c-b3d6d63d6710"},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[],"id":"c5eb79ba-2885-4de6-9f14-692c810222d5"}]}
\ No newline at end of file
+{"metadata":{"orig_nbformat":4,"language_info":{"codemirror_mode":"text/x-c++src","file_extension":".cpp","mimetype":"text/x-c++src","name":"c++","version":"17"},"kernelspec":{"name":"xcpp17","display_name":"C++17","language":"C++17"}},"nbformat_minor":5,"nbformat":4,"cells":[{"cell_type":"markdown","source":"### Task #1\n\nIn this task we want to further extend our ```VectorClass``` class. Specifically we would like add two methods and answer a question concerning ```VectorClass::print()```: \n 1. Implement missing body of VectorClass::scale()\n 1. Implement VectorClass::innerProduct(), how should the header look like?\n 1. What happens, when we call myVec.print() without arguments in main?","metadata":{},"id":"5b54f8c4-59a0-4a5a-a15c-021d20ae3d22"},{"cell_type":"markdown","source":"Let us start with (2). How should the interface for ```innerProduct()``` look like?","metadata":{},"id":"45df3877-fe76-43fd-afeb-dd4de9d969c3"},{"cell_type":"code","source":"// Your suggestions?\n\n","metadata":{},"execution_count":null,"outputs":[],"id":"a217056c-feec-46b7-aaac-5d673e57c53f"},{"cell_type":"markdown","source":"- Our vectors store entries of type ```double```. Thus, that would be a fitting return type for the value of the computed Euclidean inner product. *We could hand the result back via a parameter, too. But that is probably less convenient here.*\n- We need two vectors for the operation, so the second one should be an input argument. But:\n  - Use a reference to avoid copy generation.\n  - Not going to change the vector, so that could be const.\n- Method will not change the VectorClass object itself either, so the method could be marked const, too.\n\nSo we end up with:\n\n**``` double innerProduct( const VectorClass& second ) const;```**","metadata":{},"id":"0c933e9f-554b-455c-b023-7f8e533e75dd"},{"cell_type":"markdown","source":"***\nOkay, so below is our extended ```VectorClass``` minus the actual implementation of the two methods:","metadata":{},"id":"274868db-03d2-4c69-99e2-cbedc0f31960"},{"cell_type":"code","source":"#include <iostream>\n#include <cassert>\n\nclass VectorClass{\n    \npublic:\n\n  // ------------------------------------------------\n  // User should specify dimension at object creation\n  // ------------------------------------------------\n  VectorClass( unsigned int dim ) : dim_(dim) {\n            \n    // don't allow vectors with zero dimension\n    assert( dim_ > 0 );\n\n    // allocate memory (will throw an exception, if it fails)\n    vec_ = new double[ dim_ ];\n            \n    // be talkative ;-)\n    std::cout << \"An instance of VectorClass was generated. dim_ = \" << dim_ << std::endl;\n  }\n\n  // ----------------------------------------------------------\n  // Don't allow the default constructor\n  // [prior to C++11 you would solve this by making it private]\n  // ----------------------------------------------------------\n  VectorClass() = delete;\n\n  // ----------------------------------------------------------\n  // Don't allow the following default copy constructor either    \n  // ----------------------------------------------------------\n  VectorClass( VectorClass &other ) = delete;\n \n  // ----------------------------------------------------------\n  // We need to implement a destructor to free the dynamic memory again,\n  // otherwise we easily produce memory leaks\n  // ----------------------------------------------------------\n  ~VectorClass() {\n    std::cout << \"Going to delete memory starting at address \" << vec_ << std::endl;\n          \n    delete[] vec_;\n    std::cout << \"An instance of VectorClass was destroyed and \"\n              << dim_ * sizeof(double)\n              << \" bytes freed.\" << std::endl;\n  }\n\n  // ----------------------------------------------------------\n  // provide access to the vector's dimension\n  // ----------------------------------------------------------\n  unsigned int getDim() const { return dim_; }\n    \n  // ----------------------------------------------------------\n  // overload the [] for accessing individual entries\n  // ----------------------------------------------------------\n  double& operator[] ( unsigned int index ) {\n    assert( index != 0 && index <= dim_ );\n    return vec_[index-1];\n  }\n\n  const double& operator[] ( unsigned int index ) const {\n    assert( index != 0 && index <= dim_ );\n    return vec_[index-1];\n  }\n\n  // ----------------------------------------------------------------------\n  // pretty print vector to given output stream (default will be std::cout)\n  // ----------------------------------------------------------------------\n  void print( std::ostream &os = std::cout ) const {\n    os << \"(\";\n    for( unsigned int k = 0; k < dim_-1; k++ ) {\n      os << vec_[k] << \", \";\n    }\n    os << vec_[dim_-1] << \")\" << std::endl;\n  }\n    \n  // ----------------------------\n  // scale vector with a constant\n  // ----------------------------\n  void scale( double factor );\n    \n  // ----------------------------------------------\n  // compute Euclidean inner product of two vectors\n  // ----------------------------------------------\n  double innerProduct( const VectorClass& second ) const;\n    \n  // ----------------------------------------------------------------------\n  // add to vectors together (that's actually a little bit tricky,\n  // due to the question \"where to put the result?\"\n  // for the moment leave it with adding another vector to the one on which\n  // the method is called.\n  // ----------------------------------------------------------------------\n  void add( const VectorClass& other ) {\n\n    // make sure that input vector has correct length\n    assert( other.getDim() == dim_ );\n    for( unsigned int k = 0; k < dim_; k++ ) {\n        vec_[k] += other.vec_[k];\n    }\n  }\n    \nprivate:\n  unsigned int dim_;   // dimension of vector\n  double* vec_;        // entries of vector\n\n};","metadata":{},"execution_count":1,"outputs":[],"id":"2bcf89a4-e232-47f8-afe2-a88897f13a52"},{"cell_type":"markdown","source":"***\nNow let us implement ```scale()```","metadata":{},"id":"7ab16ac5-7f91-43cc-9a68-2e8a52dd3058"},{"cell_type":"code","source":"void VectorClass::scale( const double factor ) {\n \n    for( unsigned int k = 0; k < dim_; k++ ) {\n      vec_[k] *= factor;\n    }\n    \n}","metadata":{},"execution_count":2,"outputs":[],"id":"816a0c45-6ff9-4d67-97e7-b076bd23526d"},{"cell_type":"markdown","source":"and ```innerProduct()```","metadata":{},"id":"c84995ae-c03e-41e7-a060-f5d7b4382c55"},{"cell_type":"code","source":"double VectorClass::innerProduct( const VectorClass& second ) const {\n\n    double prod = 0.0;\n\n    for( unsigned int k = 0; k < dim_; k++ ) {\n      prod += vec_[k] * second.vec_[k];   // we have access to vec_, because we are of the same class\n    }\n\n    return prod;\n\n}   ","metadata":{},"execution_count":3,"outputs":[],"id":"139b925e-5b80-4ea8-80e9-ffb1ace29ffc"},{"cell_type":"markdown","source":"A question on ```scale()```: Why did we not make it **```void scale( const double factor ) const```** ?","metadata":{},"id":"0b36c822-eae1-4b20-b7ad-1ff1938b723c"},{"cell_type":"markdown","source":"\n\n\n\n\n\n\n\n\n\n\n\n\n","metadata":{},"id":"80b43239-51ec-4b63-af94-ce4e59fc6cc2"},{"cell_type":"markdown","source":"There are two aspects to this:\n1. The method itself cannot be marked ```const``` as it changes the state of our object, by changing values inside ```vec_```.\n1. We could mark ```factor``` as ```const```, but\n   - It is a local variable, so changes to factor would have no effect outside the body of scale() anyhow.\n   - For a basic datatype like double we are not sure if it would allow the compiler to perform some extra optimisations.\n   - Finally it is more a question of whether you think it is worth the extra effort of marking it this way.","metadata":{},"id":"9e17a14b-096c-4abb-b806-8fedc733c9fc"},{"cell_type":"markdown","source":"***\nBelow follows our test-driver that should run through now the extension was completed","metadata":{},"id":"b44bb8cd-35c0-45d5-8c0e-ee80fed8d018"},{"cell_type":"code","source":"#include <cmath>    // for using std::sqrt() below\n\nint main() {\n\n  const unsigned int dim = 10;\n  \n  // set up 1st vector\n  VectorClass myVec( dim );\n  for( unsigned int idx = 1u; idx <= dim; idx++ ) {\n    myVec[ idx ] = static_cast<double>( dim - idx + 1u );\n  }\n  myVec.print( std::cout );\n    \n  // set up 2nd vector\n  VectorClass other( dim );\n  for( unsigned int idx = 1u; idx <= dim; idx ++ ) {\n    other[ idx ] = static_cast<double>( idx );\n  }\n  other.print( std::cout );\n\n  // add the 2nd to the 1st\n  std::cout << \"\\nAdding both vectors gives: \";\n  myVec.add( other );\n  myVec.print();\n\n  // now scale second vector by 0.5\n  std::cout << \"\\nScaling the vector: \";\n  other.print();\n  std::cout << \"by 0.5 gives: \";\n  other.scale( 0.5 );\n  other.print();\n  std::cout << std::endl;\n\n  // compute the norm of the following vector\n  VectorClass vec( 2 );\n  vec[1] = 3.0;\n  vec[2] = -4.0;\n  double norm = vec.innerProduct( vec );\n  norm = std::sqrt( norm );\n  std::cout << \"Norm of vector \" << vec << \"is \" << norm << std::endl;\n  vec.print();\n  std::cout << \"is \" << norm << std::endl;\n    \n  std::cout << std::endl;\n  // now destructors will be called\n}","metadata":{},"execution_count":4,"outputs":[],"id":"6fd51fae-99a1-476c-ad9f-59529b88811e"},{"cell_type":"code","source":"main();","metadata":{},"execution_count":5,"outputs":[{"name":"stdout","text":"An instance of VectorClass was generated. dim_ = 10\n(10, 9, 8, 7, 6, 5, 4, 3, 2, 1)\nAn instance of VectorClass was generated. dim_ = 10\n(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)\n\nAdding both vectors gives: (11, 11, 11, 11, 11, 11, 11, 11, 11, 11)\n\nScaling the vector: (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)\nby 0.5 gives: (0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5)\n\nAn instance of VectorClass was generated. dim_ = 2\nNorm of vector (3, -4)\nis 5\n\nGoing to delete memory starting at address 0x55e6cfd4e580\nAn instance of VectorClass was destroyed and 16 bytes freed.\nGoing to delete memory starting at address 0x55e6d09bdf70\nAn instance of VectorClass was destroyed and 80 bytes freed.\nGoing to delete memory starting at address 0x55e6d07d8a60\nAn instance of VectorClass was destroyed and 80 bytes freed.\n","output_type":"stream"}],"id":"9c827691-afe9-4cfb-b71d-4f01bccd09c2"},{"cell_type":"markdown","source":"***\nFinally, we need to answer question (3).\n\n * In our driver we just called ```vec.print()``` without providing an output stream as argument. How did that work?\n\n * At some point we change the implementation of VectorClass::print() to have a **default value** for its os argument:  \n     **```void print( std::ostream &os = std::cout ) const```**\n     \n * Thus, if no argument is given, the compiler will automatically insert ```std::cout```.","metadata":{},"id":"067df258-3921-4328-bd14-cec60a4a02d8"},{"cell_type":"markdown","source":"#### Language Overview \n| language | optional arguments (w/ default values) | passing via keyword |\n|:---------| :-------------------------------------:|:-------------------:|\n| C        | no (only via workarounds)              | no                  |\n| C++      | yes                                    | no                  |\n| Fortran  | yes                                    | yes                 |\n| Python   | yes                                    | yes                 |\n\nPassing via keyword means, that we can set some arguments explicitely by a **name=value** pair.  \nPython example: ```print ('comma', 'separated', 'words', sep=', ')```  \n\n#### Optional Arguments in C++\n* In C++ there are some restrictions on the use of optional arguments.\n* Some of these are related to the fact that *passing via keyword* is not supported.\n* Rules are:\n  - optional arguments must follow the 'regular' ones\n  - if you do not supply a value for one optional argument, then you must also skip all arguments after that one","metadata":{},"id":"a59f1813-b205-439d-bb91-986e51df9336"},{"cell_type":"code","source":"#include <iostream>\n#include <string>\n\nvoid showVals( int a, int b = 2, double x = 1.0, std::string m = \"go\" ) {\n  std::cout << \"(\"\n            << a << \", \"\n            << b << \", \"\n            << x << \", \"\n            << m << \")\" << std::endl;\n}","metadata":{},"execution_count":7,"outputs":[],"id":"aa9570b3-2a56-4b23-acaa-48c28a781870"},{"cell_type":"code","source":"int main() {\n\n  showVals( 3 );\n  showVals( 5, 3 );\n  showVals( 1, 2, 3.0 );\n  showVals( 4, 5, 6, \"Alte Gags\" );\n\n  // showVals( 3, \"Polizei\" ); will not compile\n\n}\n\nmain();","metadata":{},"execution_count":11,"outputs":[{"name":"stdout","text":"(3, 2, 1, go)\n(5, 3, 1, go)\n(1, 2, 3, go)\n(4, 5, 6, Alte Gags)\n","output_type":"stream"}],"id":"ae9ceb03-fe74-4774-9d9c-b3d6d63d6710"},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[],"id":"c5eb79ba-2885-4de6-9f14-692c810222d5"}]}
\ No newline at end of file