-1

Moments ago i was coding some stuff... Everything went smoothly until the compiler gave me this error:

C:\Users\presgiovanni\workspace\verbaleesami\Debug/../persona.h:24: riferimento non definito a "vtable for Persona"
main.o: nella funzione "ZN7PersonaD2Ev":
C:\Users\presgiovanni\workspace\verbaleesami\Debug/../persona.h:25: riferimento non definito a "vtable for Persona"
collect2.exe: error: ld returned 1 exit status

(I'm sorry, but it's in italian, you know... It says "undefined reference to vtable for Persona")

This is the code of the header file interested (the lines are indicated with ">>"):

#ifndef PERSONA_H_
#define PERSONA_H_


#include <iostream>
using std::cout;
using std::cin;
using std::endl;
using std::ostream;
using std::istream;

#include <string>
using std::string;

class Persona{
public:
  >>    Persona(){;}
  >>    virtual ~Persona() = default;
    virtual bool login(istream&); 
    virtual ostream& print(ostream&);
protected:
    string nome, cognome, nickname, password;
};


#endif /* PERSONA_H_ */

Can someone explain me what happened (I'm working with Eclipse)? Thank you!

1 Answers1

1

You failed to provide the definition of one of the member functions, specifically the one your compiler uses to chose the translation unit to store the vtable in.

With gcc, that would be the first non-inline member function.

Defining all member functions should solve the problem.

Baum mit Augen
  • 49,044
  • 25
  • 144
  • 182
  • You're the man! I forgot, as this class was supposed to be an abstract class to me, to inizialize the member funcions listed as you said. Just a stupid lack! Thank you! – presgiovanni Dec 21 '15 at 22:22