-
-
Save daemonfire300/4188803 to your computer and use it in GitHub Desktop.
eine Funktion namens t, welche keine Argumente entgegen nimmt und einen Wert vom Typ double zur ̈ckliefert. u
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
double t() | |
{ | |
double a; | |
return a; // fehler, a wurde zwar initialisiert aber nicht deklariert also es wurde kein wert zugewiesen | |
} | |
// was du eigentlich wolltest | |
double t(double a) // nimmt argument vom type double, nennt es in seinem scope a | |
{ | |
return a; // und gibt das a im scope der funktion zurück | |
} | |
int main() | |
{ | |
double a = 3.23; | |
cout << t(a) << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment