Bonjour,

est-ce ainsi que l'on surcharge l'opérateur>> ?

Code cpp : 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
class nombre{
   nombre& entree(std::istream &flux);
};
 
std::istream& operator>> (std::istream& flux, nombre &nb);
 
nombre::nombre(std::string const &valeur_init){
...
}
 
nombre& nombre::entree(std::istream &flux){
  std::string nombre_str;
  flux>>nombre_str;
  nombre ceci(nombre_str);
  *this=ceci;
  *this=this->normalise();
  return *this;
}
 
 
std::istream& operator>>(std::istream& flux, nombre &nb){
  nb.entree(flux);
  return flux;
}
je suis preneur de toute suggestion