diff --git a/.gitignore b/.gitignore index f398dec..04fcb10 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,12 @@ exercises/2.1-class-types/test exercises/2.2-complex/test exercises/3-containers/part1/test exercises/3-containers/part2/test +exercises/4-pointers/pointers exercises/5-templates/part1/sum exercises/5-templates/part2/test +exercises/6.1-my-array/part*/my_array +exercises/6.2-special-pointers/part1/unique +exercises/6.2-special-pointers/part2/shared exercises/8-algorithm/ex exercises/9-eigen/explicit exercises/9-eigen/implicit @@ -15,3 +19,7 @@ exercises/9-eigen/sparse exercises/9-eigen/*.txt exercises/9-eigen/*.gif exercises/10-threads/area + +lectures/1-cpp-intro/auto/auto +lectures/1-cpp-intro/hello/hello +lectures/1-cpp-intro/sum/sum diff --git a/exercises/2.2-complex/README.md b/exercises/2.2-complex/README.md index 9fe8a98..d3a7289 100644 --- a/exercises/2.2-complex/README.md +++ b/exercises/2.2-complex/README.md @@ -11,7 +11,12 @@ The files `complex.hpp` and `complex.cpp` contain a partially working comple You can compile and run with: ``` -$ make && ./testc++ --std=c++14 -I../include -c -o complex.o complex.cppc++ --std=c++14 -I../include -c -o test.o test.cppc++ complex.o test.o -o test===============================================================================All tests passed (34 assertions in 6 test cases) +$ make && ./test +g++ --std=c++14 -I../include -c -o complex.o complex.cpp +g++ --std=c++14 -I../include -c -o test.o test.cpp +g++ complex.o test.o -o test +=============================================================================== +All tests passed (34 assertions in 6 test cases) ``` But to get to this point you need to complete the code and fix a few bugs! diff --git a/lectures/1-cpp-intro/README.md b/lectures/1-cpp-intro/README.md index 59964eb..a993e5a 100644 --- a/lectures/1-cpp-intro/README.md +++ b/lectures/1-cpp-intro/README.md @@ -60,6 +60,19 @@ styles that people have developed over the decades. Please ask questions any time! +--- +# A bit of history + +- C++ was originally designed as an extension of C + - Well written C tends to be legal C++ but C is not a subset of C++ + - There are programs that are valid C but not valid C++ + - However, C++ supports every programming technique supported by C + + +- Released in 1985, but first standardised in 1998 with C++98 + +- New features added to the standard over time + --- # The misunderstood monster @@ -86,20 +99,19 @@ https://commons.wikimedia.org/w/index.php?curid=3558176 - "Expert friendly" --- -# Octopus vs Swiss Army knife +# The misunderstood monster -> "C++ is an octopus made by nailing extra legs onto a dog" - Steve Taylor +- However! -.center[![:scale_img 40%](octodog.jpg) ![:scale_img 40%](sak.jpg)] +- We can pick and choose the parts of the standard we want to use -But you can cut off some extra legs to get the right dog for your -program! +- Not expected to know "all of C++" + +- Pick a subset, write some code, and gradually learn more of the language, its libraries, and its tools ??? -Why is it called C++20? -Because that's how many legs they had to nail on to "fix" the octopus. --- # The philosophy of C++ (community) @@ -119,17 +131,19 @@ Because that's how many legs they had to nail on to "fix" the octopus. --- # C++ is alive! -C++ is a work in progress. +- C++ is a work in progress. -Every three years there is a new update to the International Standard +- Every three years there is a new update to the International Standard (since C++11) -C++20 is only fully supported by MSVC (although GCC is nearly there). Major +- C++20 is only fully supported by MSVC (although GCC is nearly there). Major new features are ranges, coroutines, concepts, and modules -Latest one, C++23 has been released. Major features include +- Latest one, C++23 has been released. Major features include networking, string formatting, executors, and consolidation of new C++20 features +- Good summary of compiler support here: https://en.cppreference.com/w/cpp/compiler_support + --- # References - Bjarne Stroustrup, "Programming: Principles and Practice Using C++" diff --git a/lectures/2-classes/README.md b/lectures/2-classes/README.md index cf88050..2e12f2a 100644 --- a/lectures/2-classes/README.md +++ b/lectures/2-classes/README.md @@ -851,6 +851,23 @@ Refer back to the last slide codes and ask mutable reference then it would be a mutable ref while `auto const&` would have stayed constant) +--- +template: titleslide +# Exercise + +--- +# Note: Complex numbers + +- A complex number is a number that can be expressed in the form `a+bi` where: + - `a` is the real part + - `b` is the imaginary part + - `i` is the imaginary unit defined as the square root of `-1` +- We can define basic operations for two complex numbers `a=x+yi` and `b=u+vi` as: + - `a + b = (x + yi) + (u + vi) = (x + u) + (y + v)i` + - `a - b = (x + yi) - (u + vi) = (x - u) + (y - v)i` + +.center[![:scale_img 40%](complex_numbers.svg)] + --- # Exercise @@ -869,9 +886,9 @@ complex number class and `test.cpp` holds some basic unit tests. You can compile and run with: ``` $ make && ./test -c++ --std=c++14 -I../include -c -o complex.o complex.cpp -c++ --std=c++14 -I../include -c -o test.o test.cpp -c++ complex.o test.o -o test +g++ --std=c++14 -I../include -c -o complex.o complex.cpp +g++ --std=c++14 -I../include -c -o test.o test.cpp +g++ complex.o test.o -o test =============================================================================== All tests passed (34 assertions in 6 test cases) ``` diff --git a/lectures/2-classes/complex_numbers.svg b/lectures/2-classes/complex_numbers.svg new file mode 100644 index 0000000..89b0409 --- /dev/null +++ b/lectures/2-classes/complex_numbers.svg @@ -0,0 +1,304 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lectures/3-loops-containers/README.md b/lectures/3-loops-containers/README.md index f9477ee..2cf2ce1 100644 --- a/lectures/3-loops-containers/README.md +++ b/lectures/3-loops-containers/README.md @@ -486,4 +486,4 @@ Implement, in a new header/implementation pair of files (`map_ex.hpp`/`.cpp`), a function (`AddWord`) that adds a string to a `std::map` as the key, the value being the length of the string. Note: Copy your completed `vector_ex.cpp`/`.hpp` files from part 1. -You will want to find the documentatation for `map` on https://en.cppreference.com/ +You can find documentatation for `map` here: https://en.cppreference.com/