diff options
author | Oskar <[email protected]> | 2024-09-16 18:10:18 +0200 |
---|---|---|
committer | Oskar <[email protected]> | 2024-09-16 18:10:18 +0200 |
commit | f8b740c5b083cbb2d755b8d1adb7dea41563c9ac (patch) | |
tree | 3d43d53a3b198e0053a8cb717b472b107b2a490f | |
parent | df2ff7d92c25269d05a0bae75e0de8abd63a23d0 (diff) |
more
-rw-r--r-- | 6p52.cpp | 19 | ||||
-rw-r--r-- | 6p53.cpp | 23 | ||||
-rw-r--r-- | 6p54.cpp | 25 | ||||
-rw-r--r-- | 6p55.cpp | 40 | ||||
-rw-r--r-- | 6p56.cpp | 43 |
5 files changed, 150 insertions, 0 deletions
diff --git a/6p52.cpp b/6p52.cpp new file mode 100644 index 0000000..e2b4925 --- /dev/null +++ b/6p52.cpp @@ -0,0 +1,19 @@ + +/* + * + * 6.52 + * + * + */ + +int main () { + + /* + void manip(int, int); + double dobj; + (a) manip(āaā, āzā); // Rank 3 + (b) manip(55.4, dobj); // Rank 4 + + */ + return 0; +} diff --git a/6p53.cpp b/6p53.cpp new file mode 100644 index 0000000..c02561b --- /dev/null +++ b/6p53.cpp @@ -0,0 +1,23 @@ +#include <iostream> + +/* + * + * 6.53 + * + * + */ + +int main () { + + /* + (a) int calc(int&, int&); + int calc(const int&, const int&); // Low level const + + (b) int calc(char*, char*); + int calc(const char*, const char*); // Low level const + + (c) int calc(char*, char*); + int calc(char* const, char* const); // Top level const ignored + */ + return 0; +} diff --git a/6p54.cpp b/6p54.cpp new file mode 100644 index 0000000..f78885d --- /dev/null +++ b/6p54.cpp @@ -0,0 +1,25 @@ +#include <iostream> +#include <vector> + +/* + * + * 6.54 + * + * + */ + +int summing(int a, int b) { + + return a+b; +} + +int main () { + + int (*fpfp)(int, int) = summing; + int (*fpfp1)(int, int) = summing; + int (*fpfp2)(int, int) = summing; + int (*fpfp3)(int, int) = summing; + std::cout << fpfp(1, 1) << std::endl; + std::vector<int(*)(int, int)> funcvec = {fpfp, fpfp1, fpfp2, fpfp3}; + return 0; +} diff --git a/6p55.cpp b/6p55.cpp new file mode 100644 index 0000000..7f980e0 --- /dev/null +++ b/6p55.cpp @@ -0,0 +1,40 @@ +#include <iostream> +#include <vector> + +/* + * + * 6.54 + * + * + */ + +int summing(int a, int b) { + + return a + b; +} + +int subtracting(int a, int b) { + + return a - b; +} + +int multiplying(int a, int b) { + + return a * b; +} + +int dividing(int a, int b) { + + return a / b; +} + +int main () { + + int (*fpfp)(int, int) = summing; + int (*fpfp1)(int, int) = subtracting; + int (*fpfp2)(int, int) = multiplying; + int (*fpfp3)(int, int) = dividing; + std::cout << fpfp(1, 1) << std::endl; + std::vector<int(*)(int, int)> funcvec = {fpfp, fpfp1, fpfp2, fpfp3}; + return 0; +} diff --git a/6p56.cpp b/6p56.cpp new file mode 100644 index 0000000..12e91e9 --- /dev/null +++ b/6p56.cpp @@ -0,0 +1,43 @@ +#include <iostream> +#include <vector> + +/* + * + * 6.54 + * + * + */ + +int summing(int a, int b) { + + return a + b; +} + +int subtracting(int a, int b) { + + return a - b; +} + +int multiplying(int a, int b) { + + return a * b; +} + +int dividing(int a, int b) { + + return a / b; +} + +int main () { + + int (*fpfp)(int, int) = summing; + int (*fpfp1)(int, int) = subtracting; + int (*fpfp2)(int, int) = multiplying; + int (*fpfp3)(int, int) = dividing; + std::vector<int(*)(int, int)> funcvec = {fpfp, fpfp1, fpfp2, fpfp3}; + for(auto a : funcvec) { + std::cout << a(10, 10) << std::endl; + } + + return 0; +} |