From df2ff7d92c25269d05a0bae75e0de8abd63a23d0 Mon Sep 17 00:00:00 2001 From: Oskar Date: Mon, 16 Sep 2024 14:39:48 +0200 Subject: more --- 6p47.cpp | 34 ++++++++++++++++++++++++++++++++++ 6p48.cpp | 17 +++++++++++++++++ 6p49.cpp | 14 ++++++++++++++ 6p50.cpp | 23 +++++++++++++++++++++++ 6p51.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 136 insertions(+) create mode 100644 6p47.cpp create mode 100644 6p48.cpp create mode 100644 6p49.cpp create mode 100644 6p50.cpp create mode 100644 6p51.cpp diff --git a/6p47.cpp b/6p47.cpp new file mode 100644 index 0000000..431d8b0 --- /dev/null +++ b/6p47.cpp @@ -0,0 +1,34 @@ +#include +#include +#include +#define NDEBUG +/* + * + * 6.47 + * + * + */ + +void recursive_vec_print(std::vector::const_iterator cbeg, std::vector::const_iterator cend) { + + if(cbeg == cend) { + return; + } + + std::cout << *cbeg++ << std::endl; + assert((cend - cbeg) != -1); + #ifndef NDEBUG + std::cerr << cend - cbeg << std::endl; + std::cerr << __FILE__ << std::endl; + std::cerr << __func__ << std::endl; + std::cerr << __LINE__ << std::endl; + #endif + recursive_vec_print(cbeg, cend); +} + +int main () { + + std::vector myvec = {1,2,32,44,2,24,1,62,24}; + recursive_vec_print(myvec.cbegin(), myvec.cend()); + return 0; +} diff --git a/6p48.cpp b/6p48.cpp new file mode 100644 index 0000000..3b35df0 --- /dev/null +++ b/6p48.cpp @@ -0,0 +1,17 @@ + +/* + * + * 6.48 + * + * + */ + +int main () { + + /* + std::string s; + while (std::cin >> s && s != sought) { } + assert(std::cin); + */ + return 0; +} diff --git a/6p49.cpp b/6p49.cpp new file mode 100644 index 0000000..82582d1 --- /dev/null +++ b/6p49.cpp @@ -0,0 +1,14 @@ + +/* + * + * 6.49 + * + * + */ + +int main () { + + // What is a candidate function? A function with the same name as the function being called, could be one or more + // What is a viable function? It must have same number of parameters as arguments in the calling function, and the types must match or be convertible. + return 0; +} diff --git a/6p50.cpp b/6p50.cpp new file mode 100644 index 0000000..1ec8cc9 --- /dev/null +++ b/6p50.cpp @@ -0,0 +1,23 @@ + +/* + * + * 6.50 + * + * + */ + +int main () { + + /* + 1 // void f(); + 2 // void f(int); + 3 // void f(int, int); + 4 // void f(double, double = 3.14); + + (a) ambiguous? + (b) 2 + (c) 3 + (d) 4 + */ + return 0; +} diff --git a/6p51.cpp b/6p51.cpp new file mode 100644 index 0000000..96f7dd4 --- /dev/null +++ b/6p51.cpp @@ -0,0 +1,48 @@ +#include + +/* + * + * 6.51 + * + * + */ + +void f() { + + std::cout << "f()" << std::endl; +} + +void f(int i) { + + std::cout << "f(int) " << i << std::endl; +} + +void f(int i, int j) { + + std::cout << "f(int, int) " << i << " " << j << std::endl; +} + +void f(double a, double b = 3.14) { + + std::cout << "f(double, double) " << a << " " << b << std::endl; +} + +int main () { + + /* + 1 // void f(); + 2 // void f(int); + 3 // void f(int, int); + 4 // void f(double, double = 3.14); + + (a) ambiguous? + (b) 2 + (c) 3 + (d) 4 + */ + // f(2.56, 42); Ambiguous + f(42); + f(42, 0); + f(2.56, 3.14); + return 0; +} -- cgit v1.2.3