Virtual C++

#include <cstdlib>
#include<iostream>
using namespace std;

/*
 * 
 */

class Persona
{
protected:
    string nome;
    
public:   
    Persona()
    {
        
    }
    Persona(string nome)
    {
        this->nome=nome;
    }
  
     string get_Nome()
    {
        return nome;
    }
    void set_Nome(string nome)
    {
        this->nome=nome;
    }
    
};

class Dipendente:public Persona
{
public:
    
    Dipendente(string nome)
    {
        this->nome=nome;
    }
    string get_Nome()
    {
        return "Dipendente :"+ nome;
    }
    
    
};



int main(int argc, char** argv) {

    
    Persona m("Mario");
    
    /*costruttore di copia: copia m in M*/
    Persona M(m);
    
    cout<<m.get_Nome()<<endl;//out Mario
    cout<<M.get_Nome()<<endl;// out Mario
    
    m.set_Nome("Gianni");
    cout<<m.get_Nome()<<endl;//out Gianni
    cout<<M.get_Nome()<<endl;// out Mario
    
    
    Dipendente *d=new Dipendente("Gianni");
    
    cout<<d->get_Nome()<<endl;//out Dipendente :Gianni
    
    Persona *p=NULL;
    p=new Dipendente("Luca");
    
    cout<<p->get_Nome()<<endl;//out Luca se NON VIRTUAL, altrimenti Dipendente: Luca se VIRTUAL
    
    
    return 0;
}