PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

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

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