2.12.1 Le fichier shadok.h

Voici à quoi doit ressembler votre fichier shadok.h :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef __SHADOK_H__
#define __SHADOK_H__

#include <iostream>
#include <string>

namespace ShadokOption{
	enum Type{
		SHADOKDUHAUT,
		SHADOKDUBAS,
	};
};

class Shadok{
	public:
		Shadok(const std::string & nom = "", unsigned int age = 0, ShadokOption::Type type = ShadokOption::SHADOKDUHAUT);
		Shadok(const Shadok & shadok);
		~Shadok();
		
		void setNom(const std::string & nom);
		void setAge(unsigned int age);
		void setType(ShadokOption::Type type);
		
		void parler();
		void pomper();
		
		
		Shadok & operator = (const Shadok & shadok);
		Shadok & operator << (const std::string & nom);
		Shadok & operator << (unsigned int age);
		Shadok & operator << (ShadokOption::Type type);
		
		friend bool operator == (const Shadok & shadok1, const Shadok & shadok2);
		friend bool operator != (const Shadok & shadok1, const Shadok & shadok2);
		friend std::ostream & operator << (std::ostream & out, const Shadok & shadok);
		friend std::istream & operator >> (std::istream & in, Shadok & shadok);
		
	private:
		void initialisationShadok(const std::string & nom, unsigned int age, ShadokOption::Type type);
		void copyShadok(const Shadok & shadok);
		std::string p_nom;
		unsigned int p_age;
		ShadokOption::Type p_type;
};

#endif

Voilà, pour le fichier shadok.h.