vendredi 25 janvier 2019

Undefined reference to class using Prototype Patterns

Hello i want to implement a base type of Prototype Patterns in order to, in my case, clone the 2 clsses

I tried implementing the copy constructor on the 2 child classes, and the clone on the children and in the main class

class Persona {
   public:
      Persona();
      virtual Persona* Clone() = 0;
}

class Studente : public Persona {
   protected:
    string facolta;
    string corso;

   public:
    Studente();
    Studente(const Studente& s) {
        facolta = s.facolta;
        corso = s.corso;
    }
    virtual Persona* Clone(){
        return new Studente(*this);
    }
 }

class Docente : public Persona {
  protected:
    string corsi;
  public:
    Docente();

    Docente(const Docente& d) {
        corsi = d.corsi;
    }
    virtual Persona* Clone(){
        return new Docente(*this);
    }    
}

I tried to remove all the Clone() and it works, i tried to declare in the classes the return new Studente, without the parameter this, but gives the same error. I see online some example and do that similar, for the copy constructor i insert all classes variables/variable.

Thank you

Aucun commentaire:

Enregistrer un commentaire