Skip to content

Instantly share code, notes, and snippets.

@aoloe
Last active October 3, 2018 09:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aoloe/5431de9056897d498c639cc179137be2 to your computer and use it in GitHub Desktop.
Save aoloe/5431de9056897d498c639cc179137be2 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
#include <cassert>
std::string get_alter_typ(int alter)
{
std::string typ{}; // typ definiert
if (alter < 18) // alter vergleichen
{
typ = "jung"; // typ setzen
}
else
{
typ = "alt";
}
return typ; // typ zurückgeben
}
int main()
{
std::string typ_01 = get_alter_typ(12);
assert(typ_01 == "jung"); // sicherstellen, das 12 gibt jung
std::string typ_02 = get_alter_typ(19);
assert(typ_02 == "alt"); // sicherstellen, das 12 gibt jung
int alter{0};
std::cout << "Alter? ";
std::cin >> alter;
std::cout << get_alter_typ(alter) << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment