From 59c3d4a1a43a1072f5912004842c23891b738dd2 Mon Sep 17 00:00:00 2001 From: nmannall Date: Fri, 18 Apr 2025 13:39:07 +0100 Subject: [PATCH 1/6] Add missing executables to .gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index f398dec..a851310 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 From 1ce0a88643ff7419a7fc824ed1b8607cd3cc4fd2 Mon Sep 17 00:00:00 2001 From: nmannall Date: Tue, 22 Apr 2025 20:45:42 +0100 Subject: [PATCH 2/6] Correct terminal output in exercise 2.2 README --- exercises/2.2-complex/README.md | 7 ++++++- lectures/2-classes/README.md | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) 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/2-classes/README.md b/lectures/2-classes/README.md index cf88050..81d29cc 100644 --- a/lectures/2-classes/README.md +++ b/lectures/2-classes/README.md @@ -869,9 +869,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) ``` From d548b85b95d479fb1ab3bede475fd781989d8c2a Mon Sep 17 00:00:00 2001 From: nmannall Date: Tue, 22 Apr 2025 21:04:47 +0100 Subject: [PATCH 3/6] Add complex number reminder slide --- lectures/2-classes/README.md | 17 ++ lectures/2-classes/complex_numbers.svg | 304 +++++++++++++++++++++++++ 2 files changed, 321 insertions(+) create mode 100644 lectures/2-classes/complex_numbers.svg diff --git a/lectures/2-classes/README.md b/lectures/2-classes/README.md index 81d29cc..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 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 From 1dceb19933e44712f135e4641a82dc87470d2c7e Mon Sep 17 00:00:00 2001 From: nmannall Date: Tue, 22 Apr 2025 22:06:06 +0100 Subject: [PATCH 4/6] Update C++ intro slides --- lectures/1-cpp-intro/README.md | 36 +++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) 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++" From 4035bb01cbfdb86935e73eb9f29a10269a34f2ce Mon Sep 17 00:00:00 2001 From: nmannall Date: Tue, 22 Apr 2025 22:13:35 +0100 Subject: [PATCH 5/6] Add intro examples to .gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index a851310..04fcb10 100644 --- a/.gitignore +++ b/.gitignore @@ -19,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 From b67589b473384aa01c0068c6fc5a4cb5644571f8 Mon Sep 17 00:00:00 2001 From: nmannall Date: Wed, 23 Apr 2025 00:00:45 +0100 Subject: [PATCH 6/6] Shorten slide so text doesn't overflow --- lectures/3-loops-containers/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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/