PageRenderTime 86ms CodeModel.GetById 21ms RepoModel.GetById 3ms app.codeStats 0ms

/trunk/Examples/ruby/mark_function/example.h

#
C++ Header | 49 lines | 30 code | 11 blank | 8 comment | 0 complexity | 9dd5ee473a44a6b1b1efe4a501478e39 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. #ifndef _EXAMPLE_H_
  2. #define _EXAMPLE_H_
  3. #include <vector>
  4. #include <string>
  5. class Animal
  6. {
  7. protected:
  8. std::string name_;
  9. public:
  10. // Construct an animal with a name
  11. Animal(const char* name);
  12. // Destruct an animal
  13. ~Animal();
  14. // Return the animal's name
  15. const char* get_name() const;
  16. };
  17. class Zoo
  18. {
  19. private:
  20. typedef std::vector<Animal*> AnimalsType;
  21. typedef AnimalsType::iterator IterType;
  22. protected:
  23. AnimalsType animals;
  24. public:
  25. Zoo();
  26. ~Zoo();
  27. /* Create a new animal */
  28. static Animal* create_animal(const char* name);
  29. /* Add a new animal to the zoo */
  30. void add_animal(Animal* animal);
  31. /* Remove an animal from the zoo */
  32. Animal* remove_animal(size_t i);
  33. /* Return the number of animals in the zoo */
  34. size_t get_num_animals() const;
  35. /* Return a pointer to the ith animal */
  36. Animal* get_animal(size_t i) const;
  37. };
  38. #endif /*_EXAMPLE_H_*/