Probleme de surcharge d'operator<<
Voici mon problème:
J'ai un fichier .h qui ressemble à ça.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| #ifndef PERSONNE_H
#define PERSONNE_H
class Personne
{
protected:
char * nom;
char * pnom;
int age;
public:
//friend class Appreciation;
Personne(); // personne par defaut
Personne(char * n, char * p, int a);
Personne(Personne& p); // constructeur copie
Personne operator=(Personne& p); // operator d'affectation
~Personne();
void Modifier();
void virtual Afficher();
void virtual afficher(std::ostream& out);
};
#endif |
ensuite
dans main() j'ai la définition suivant:
Code:
1 2 3 4
| void Personne::afficher(ostream& out)
{
out << "Fonction affichage...." << endl;
} |
plus loin, juste avant main() j'ai un truc qui ressemble à ça:
Code:
1 2 3 4 5
| ostream &operator<<( ostream &out, Personne &pers )
{
pers.afficher(out) ;
return out;
} |
.. et enfin la cerise sur le gateau, j'ai une erreur belle comme ça:
Code:
no `void Personne::afficher(std::ostream&)' member function declared in class `Personne'
..C'est grave docteur? :f1: