examples/XSpp-Example/src/Animal.h
raw| 1 | #ifndef _Animal_h_ |
| 2 | #define _Animal_h_ |
| 3 | |
| 4 | #include <string> |
| 5 | #include <exception> |
| 6 | |
| 7 | class CannotMakeSoundException : public std::exception { |
| 8 | public: |
| 9 | virtual const char* what() const throw() |
| 10 | { return "This animal does not make sounds."; } |
| 11 | }; |
| 12 | |
| 13 | class Animal { |
| 14 | public: |
| 15 | Animal(const std::string& name); |
| 16 | |
| 17 | void SetName(const std::string& newName); |
| 18 | std::string GetName() const; |
| 19 | |
| 20 | void MakeSound() const; |
| 21 | |
| 22 | private: |
| 23 | std::string fName; |
| 24 | }; |
| 25 | |
| 26 | #endif |