diff options
Diffstat (limited to 'libhello/libhello/hello.cxx')
-rw-r--r-- | libhello/libhello/hello.cxx | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/libhello/libhello/hello.cxx b/libhello/libhello/hello.cxx index 677815d..4fbd917 100644 --- a/libhello/libhello/hello.cxx +++ b/libhello/libhello/hello.cxx @@ -1,16 +1,17 @@ -// file: libhello/hello.cxx -*- C++ -*- - #include <libhello/hello.hxx> -#include <iostream> +#include <ostream> +#include <stdexcept> using namespace std; namespace hello { - void - say (const string& n) + void say_hello (ostream& o, const string& n) { - cout << "Hello, " << n << '!' << endl; + if (n.empty ()) + throw invalid_argument ("empty name"); + + o << "Hello, " << n << '!' << endl; } } |