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
| class produit {
string nom;
int prix;//en centimes.
public:
produit(string const& nom, int prix);
string nom() const;
int prix() const;//en centimes.
}
produit demander_produit();
//voire même
std::istream& operator>>(std::istream&, produit &);
//pour l'affichage
std::ostream& operator<<(std::ostream&, produit const&);
//une classe extérieure:
class entrepot {
collection<produit> produits; // une map? un vector?
public:
entrepot& operator<<(produit const& p) {produits.add(p); return *this;}
//les itérateurs classiques
const_iterator& begin() const;
//...
entrepot& remove(produit const& p);
};
//pour l'affichage
std::ostream& operator<<(std::ostream&, entrepot const&); |
Partager