From 8644ec6252d2ec44d8a549253049f3a0de2c9494 Mon Sep 17 00:00:00 2001 From: Oskar Date: Thu, 12 Sep 2024 15:15:45 +0200 Subject: more --- 6p43.cpp | 16 ++++++++++++++++ 6p44.cpp | 19 +++++++++++++++++++ 6p45.cpp | 11 +++++++++++ 6p46.cpp | 30 ++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+) create mode 100644 6p43.cpp create mode 100644 6p44.cpp create mode 100644 6p45.cpp create mode 100644 6p46.cpp diff --git a/6p43.cpp b/6p43.cpp new file mode 100644 index 0000000..2055868 --- /dev/null +++ b/6p43.cpp @@ -0,0 +1,16 @@ + +/* + * + * 6.43 + * + * + */ + +int main () { + + /* + (a) inline bool eq(const BigInt&, const BigInt&) {...} // header only + (b) void putValues(int *arr, int size); // Source file or header + */ + return 0; +} diff --git a/6p44.cpp b/6p44.cpp new file mode 100644 index 0000000..06fb402 --- /dev/null +++ b/6p44.cpp @@ -0,0 +1,19 @@ +#include + +/* + * + * 6.44 + * + * + */ + +inline bool isShorter(const std::string &s1, const std::string &s2) { + + return s1.size() < s2.size(); +} + +int main () { + + std::cout << (isShorter("1234", "12345") ? "True" : "False") << std::endl; + return 0; +} diff --git a/6p45.cpp b/6p45.cpp new file mode 100644 index 0000000..f23176b --- /dev/null +++ b/6p45.cpp @@ -0,0 +1,11 @@ + +/* + * + * 6.45 + * + * + */ + +int main () { + return 0; +} diff --git a/6p46.cpp b/6p46.cpp new file mode 100644 index 0000000..6e1d085 --- /dev/null +++ b/6p46.cpp @@ -0,0 +1,30 @@ +#include + +/* + * + * 6.46 + * + * + */ + +/* + Quick note. Giving constexpr to this function will not work for C++ + standards before C++20. If we go by the book this would not work if we + were compiling for C++11 - C++17 + + This will compile and will work if we are compiling for C++20 + */ + +constexpr bool isShorter(const std::string &s1, const std::string &s2) { + + return s1.size() < s2.size(); +} + +int main () { + + std::cout << (isShorter("1234", "12345") ? "True" : "False") << std::endl; + std::string fourlen = "1234"; + std::string fivelen = "12345"; + std::cout << (isShorter(fourlen, fivelen) ? "True" : "False") << std::endl; + return 0; +} -- cgit v1.2.3