diff --git a/ax_funktions.hpp b/ax_funktions.hpp index f5a34dc..b49111e 100644 --- a/ax_funktions.hpp +++ b/ax_funktions.hpp @@ -9,6 +9,12 @@ namespace ax{ std::cout << "Das doppelte der Zahl ist: " << x*2 << std::endl; } + void print_char(char x) + { + std::cout << x; + } + + int sqrt(int x){ return x*x; @@ -17,4 +23,22 @@ namespace ax{ char shift(char x){ return x-1; } + + //allgmeine Funktion Deklaration ohne Argumente oder returns für einen unbekannten Datentyp + template std::string type_name(); + + //Spezialisierte Implementation von type_name() für einen entsprechenden Datentyp vgl. mit überladung + template<> std::string type_name() {return "Integer";} + template<> std::string type_name(){return "Char";} + template<> std::string type_name(){return "Float";} + template<> std::string type_name(){return "Double";} + template<> std::string type_name(){return "Bool";} + + + + + template + void ausgebene(T a){ + std::cout << a << " ist vom Type " << type_name()<< std::endl ; + } } \ No newline at end of file diff --git a/main.cpp b/main.cpp index a46f6a4..a7f7ccf 100644 --- a/main.cpp +++ b/main.cpp @@ -1,8 +1,10 @@ #include +#include #include "ax_funktions.hpp" int number = 12; +char Buchstabe = 'a'; main() { @@ -19,8 +21,17 @@ main() ax::print_number(ax::sqrt(3)); - std::cout << "a " << "wird zu: " << ax::shift('a')<< std::endl; + for (int i = 0; i < 26; i++) + { + ax::print_char(Buchstabe+i); + std::cout<< " wird zu: " << ax::shift(Buchstabe + i)<< std::endl; + } + + double testdouble = 3.1416; + + ax::ausgebene(Buchstabe); + ax::ausgebene(42); + ax::ausgebene(true); + ax::ausgebene(testdouble); - //test - }; \ No newline at end of file