parent
b5f2ce2a01
commit
902bf7c255
@ -0,0 +1,47 @@
|
||||
#include <iostream>
|
||||
#include "Personne2.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace reseau2;
|
||||
|
||||
Personne::Personne(const string& prenom): prenom{prenom}{
|
||||
cout << prenom << " créé\n";
|
||||
}
|
||||
|
||||
const string& Personne::getPrenom() const {
|
||||
return this->prenom;
|
||||
}
|
||||
|
||||
bool Personne::ajoutListe(const Personne& unePersonne) {
|
||||
if(lesPersonnes.empty()){
|
||||
cout << "Personne ajoutée " << unePersonne <<"\n";
|
||||
lesPersonnes.push_back(unePersonne);
|
||||
return true;
|
||||
}
|
||||
if(unePersonne.getPrenom()==this->prenom)
|
||||
return false;
|
||||
else {
|
||||
cout << "Personne ajoutée " << unePersonne <<"\n";
|
||||
lesPersonnes.push_back(unePersonne);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void Personne::affichListe() {
|
||||
for(list<Personne>::const_iterator it2 = lesPersonnes.cbegin(); it2 != lesPersonnes.cend(); ++it2)
|
||||
cout << *it2 << "\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
ostream& reseau2::operator<<(ostream& os, Personne p) {
|
||||
return os << p.getPrenom();
|
||||
}
|
||||
|
||||
bool reseau2::operator==(Personne p1, Personne p2){
|
||||
if(p1.getPrenom()==p2.getPrenom())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
Personne::~Personne() {}
|
Loading…
Reference in new issue