Skip to content

Instantly share code, notes, and snippets.

@aoloe aoloe/assert_alter.cpp
Last active Oct 3, 2018

Embed
What would you like to do?
#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
You can’t perform that action at this time.