summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--6p47.cpp34
-rw-r--r--6p48.cpp17
-rw-r--r--6p49.cpp14
-rw-r--r--6p50.cpp23
-rw-r--r--6p51.cpp48
5 files changed, 136 insertions, 0 deletions
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 <iostream>
+#include <vector>
+#include <cassert>
+#define NDEBUG
+/*
+ *
+ * 6.47
+ *
+ *
+ */
+
+void recursive_vec_print(std::vector<int>::const_iterator cbeg, std::vector<int>::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<int> 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 <iostream>
+
+/*
+ *
+ * 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;
+}