From f8b740c5b083cbb2d755b8d1adb7dea41563c9ac Mon Sep 17 00:00:00 2001 From: Oskar Date: Mon, 16 Sep 2024 18:10:18 +0200 Subject: more --- 6p52.cpp | 19 +++++++++++++++++++ 6p53.cpp | 23 +++++++++++++++++++++++ 6p54.cpp | 25 +++++++++++++++++++++++++ 6p55.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 6p56.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 150 insertions(+) create mode 100644 6p52.cpp create mode 100644 6p53.cpp create mode 100644 6p54.cpp create mode 100644 6p55.cpp create mode 100644 6p56.cpp 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 + +/* + * + * 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 +#include + +/* + * + * 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 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 +#include + +/* + * + * 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 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 +#include + +/* + * + * 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 funcvec = {fpfp, fpfp1, fpfp2, fpfp3}; + for(auto a : funcvec) { + std::cout << a(10, 10) << std::endl; + } + + return 0; +} -- cgit v1.2.3