From 3ac7122589e18174e87ee5a6c68fb8b9112fe1ba Mon Sep 17 00:00:00 2001 From: Arotex Date: Sat, 4 Oct 2025 10:47:38 +0200 Subject: [PATCH] =?UTF-8?q?funktionsheader=20und=20funktionsnamespace=20hi?= =?UTF-8?q?nzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ax_funktions.hpp | 16 ++++++++++++++++ main.cpp | 22 ++++------------------ 2 files changed, 20 insertions(+), 18 deletions(-) create mode 100644 ax_funktions.hpp diff --git a/ax_funktions.hpp b/ax_funktions.hpp new file mode 100644 index 0000000..6b88b1a --- /dev/null +++ b/ax_funktions.hpp @@ -0,0 +1,16 @@ +//Funktionsdeklaration ax_funktions.hpp + +#pragma once + +namespace ax{ + void print_number(int x) + { + std::cout << "Die Zahl ist: " << x << std::endl; + std::cout << "Das doppelte der Zahl ist: " << x*2 << std::endl; + } + + + int sqrt(int x){ + return x*x; + } +} \ No newline at end of file diff --git a/main.cpp b/main.cpp index 6a94f5a..9ae665e 100644 --- a/main.cpp +++ b/main.cpp @@ -1,9 +1,8 @@ #include +#include "ax_funktions.hpp" int number = 12; -void print_number (int); -int sqrt (int); main() { @@ -15,22 +14,9 @@ main() for (int i = 0; i < 2; i++) { - print_number(i); // neue Funktion unsicher und unvollständig + ax::print_number(i); // neue Funktion unsicher und unvollständig } - print_number(sqrt(3)); + ax::print_number(ax::sqrt(3)); -}; - - - -void print_number(int x) -{ - std::cout << "Die Zahl ist: " << x << std::endl; - std::cout << "Das doppelte der Zahl ist: " << x*2 << std::endl; -} - - -int sqrt(int x){ - return x*x; -} \ No newline at end of file +}; \ No newline at end of file