'undefined reference to `vtable for Class` in destructor

im trying to build a simple element character type game in c++. Having an abstract class Personaje and a child class called Agua. Im having an error for undefined reference on `vtable for Agua` , im not understading the issue here. In advance thanks for your time. Im new in c++ and im trying to learn POO.

Personaje.h

#ifndef PERSONAJE_H_
#define PERSONAJE_H_

#include "../header.h"


class Personaje
{
public:
    string name;
    int vida;
    int energia;
    int escudo;
    Personaje(string n, int v, int en, int es)
    {
        name = n;
        vida = v;
        energia = en;
        escudo = es;
    }

    virtual int alimentar() = 0;
};

#endif

Agua.h

#ifndef AGUA_H_
#define AGUA_H_

#include "../../header.h"
#include "../../Personaje/Personaje.h"

class Agua : public Personaje
{

private:
    int vecesAlimentado = 0;

public:
    Agua(string n, int v, int en, int es)
        : Personaje(n, v, en, es){};
    int alimentar();
};

#endif

main.cpp

#include "header.h"

int main() {    
    Agua agua("kure", 80, 0, 1);
    
    return 0;
}

Agua.cpp

#include "agua.h"

int Agua::alimentar()
{
    if (energia + 10 <= 20)
    {
        energia += 10;
        cout << name << "fue alimentado con plancton.";
        return energia;
    }
    cout << this->name << "no puede ser alimentado.";
    return energia;
}

header.h

#ifndef HEADER_H_
#define HEADER_H_

using namespace std;

#include <iostream>
#include <time.h>
#include <limits>
#include <string>
#include "./Personaje/Personaje.h"
#include "./personajes/agua/agua.h"

#endif

error

/usr/bin/ld: /tmp/ccqv1IKK.o: in function Agua::Agua(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, int, int)': /home/kurepa/programming/AYP2/TP2/./personajes/agua/agua.h:15: undefined reference to vtable for Agua' /usr/bin/ld: /tmp/ccqv1IKK.o: in function Agua::~Agua()': /home/kurepa/programming/AYP2/TP2/./personajes/agua/agua.h:7: undefined reference to vtable for Agua' collect2: error: ld returned 1 exit status

c++


Solution 1:[1]

try replacing

int alimentar();

with int alimentar(){}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ricardo Veloz