Come compilatore uso gcc.
Interfaccia Docente
codice:
#define DOCENTE_H
#include<string>
using std:: string;
#include <iostream>
using std :: istream;
using std :: ostream;
class Docente{
friend ostream& operator<<(ostream&, const Docente&);
friend istream& operator>>(istream&, Docente&);
public:
Docente(string, string);
void stampa();
string getNome();
string getCognome();
private:
string nome,cognome;
};
#endif
Docente.cpp
codice:
#include "Docente.h"
#include <iostream>
using std :: cout;
using std :: endl;
using std ::istream;
using std :: ostream;
#include <string>
using std :: string;
Docente :: Docente(string n, string c){
nome = n;
cognome = c;
}
void Docente :: stampa(){
cout << "Docente : " << nome << cognome;
}
string Docente :: getNome(){
return nome;
}
string Docente :: getCognome(){
return cognome;
}
ostream& operator<<(ostream& out,const Docente &d){
out << d.nome << " "<< d.cognome;
return out;
}
istream& operator>>(istream& in, Docente &d){
string n,c;
in >> n >> c;
d.nome = n;
d.cognome = c;
return in;
}