After doing several tests I verified that it is not possible to use abstract classes in a simple way, however it is possible to use virtual methods and overwriting them in the child classes. Although the classes are not abstract, at least the methods and methods can be overwritten. do something similar.
I declare the virtual method

I implement the virtual method

I override the virtual method

I implement virtual method on writing and also call the parent method, if necessary.

THIS WOULD LOOK LIKE IN VScode




I leave the example the father and daughter class
parent class
.h
// Godot engine C++ Gdnative Estructura de un archivo
#ifndef PERSONAJEABSTRACTO_H
#define PERSONAJEABSTRACTO_H
#pragma once
#include <Godot.hpp>
#include <KinematicBody.hpp>
namespace godot {
//Testing an abstract class with C ++ for use with GDnative, ojo funciona con clases abstractas simuladas
class PersonajeAbstracto : public KinematicBody {
private:
GODOT_CLASS(PersonajeAbstracto, KinematicBody)
public:
PersonajeAbstracto();
~PersonajeAbstracto();
void _init();
void _ready();
static void _register_methods();
protected:
// virtual for overwriting
virtual void Walk();
// virtual for overwriting
virtual void Run();
// virtual for overwriting
virtual void Attack();
// virtual for overwriting
virtual void Jump();
};
}
#endif
.cpp
#include "PersonajeAbstracto.h"
using namespace godot;
PersonajeAbstracto::PersonajeAbstracto() {}
PersonajeAbstracto::~PersonajeAbstracto() {}
void PersonajeAbstracto::_init() {}
void PersonajeAbstracto::_ready() {}
void PersonajeAbstracto::Walk() { Godot::print("DESDE CLASE PADRE"); }
void PersonajeAbstracto::Run() {}
void PersonajeAbstracto::Attack() {}
void PersonajeAbstracto::Jump() {}
void PersonajeAbstracto::_register_methods()
{
}
Daughter class
.h
#ifndef MOMIA_H
#define MOMIA_H
#pragma once
#include <Godot.hpp>
#include "PersonajeAbstracto.h"
#include "KinematicBody.hpp"
namespace godot {
class Momia : public PersonajeAbstracto {
private:
GODOT_CLASS(Momia, PersonajeAbstracto)
public:
Momia();
~Momia();
static void _register_methods();
//metodo inicial siempre hay que declararlo
void _init();
void _ready();
private:
// I override the function and call the parent method at the same time
void Walk() override;
void delay(int secs);
};
}
#endif
.cpp
#include "Momia.h"
using namespace godot;
Momia::Momia()
{
}
Momia::~Momia()
{
}
void Momia::_init()
{
}
void Momia::_ready()
{
Walk();
}
void Momia::Walk()
{
PersonajeAbstracto::Walk();// If you want you can call the parent method
Godot::print("DESDE CLASE LA MOMIA");
}
void Momia::_register_methods()
{
register_method("_ready",&Momia::_ready);
}