Bonjour,
Voici mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
47
48
49
50
51
52
53
54
55
56
57
58
 
#include <iostream>
#include <cmath>
using namespace std;
 
enum Pavillon { JollyRogers, CompagnieDuSenegal, CompagnieDOstende };
 
enum Etat { Intact, Endommage, Coule };
 
int sq(int x)
{
  return x*x;
}
 
class Coordonnees
{
public:
  Coordonnees(int un_x, int un_y) : x_(un_x), y_(un_y) {}
  int x() const {
    return x_;
  }
  int y() const {
    return y_;
  }
  void operator+=(Coordonnees const& autre); 
private:
  int x_;
  int y_;
};
 
class Navire
{
private:
	Coordonnees position_;
protected:
	Pavillon pavillon_;
	Etat etat_;
public:
	Navire(int x, int y, Pavillon p) :
		position_(x, y), 
		pavillon_(p), 
		etat_(Etat::Intact) {};
	Coordonnees position() const { return position_;  }
	void avancer(int de_x, int de_y) {
		position_ += Coordonnees(de_x, de_y);
	}
	void renflouer() { etat_ = Etat::Intact; }
	friend std::ostream& operator <<(std::ostream&, const Coordonnees&); 
	void afficher(ostream& sortie) const {
		sortie << " en " << position_
			   << " battant pavillon " << pavillon_
			   << ", " << etat_;
	}
};
ostream& operator<< (ostream& sortie, Coordonnees const& c) {
	sortie << "(" << c.x() << ", " << c.y() << ")";
	return sortie;
}
J'ai eu deux erreurs:
L'une au niveau de :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
	Navire(int x, int y, Pavillon p) :
et l'autre au niveau:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
sortie << " en " << position_
erreur: cannot bind 'std::basic_ostream<char>' lvalue to 'std::basic_ostream<char>&&'

Avez-vous une idée ?
Merci d'avance pour l'aide.
Cordialement.