I've been trying to create a particle system that relies on a main class "Particle" that is then inherited by other classes such as "NormalParticle". I want to have the "Particle" class have sf::Drawable and then have the draw() function declared in the child classes, so that I can have a vector of *Particle from which I can use directly window.draw(
particle );
ParticleSystem.h
#ifndef PARTICLESYSTEM_H
#define PARTICLESYSTEM_H
#include<queue>
#include<SFML/Graphics.hpp>
namespace GT
{
class Particle
{
public:
sf::Vector2f position;
Particle();
};
class NormalParticle : public GT::Particle, public sf::Drawable
{
public:
NormalParticle();
private:
void draw(sf::RenderTarget& target, sf::RenderStates states) const;
};
}
#endif // PARTICLESYSTEM_H
ParticleSystem.cpp
#include "ParticleSystem.h"
GT::Particle::Particle()
{
}
GT::NormalParticle::NormalParticle()
{
}
main.cpp
#include<iostream>
#include<SFML/Graphics.hpp>
#include"ParticleSystem.h"
using namespace std;
int main()
{
sf::RenderWindow window(sf::VideoMode(1000, 800), "");
GT::NormalParticle p;
sf::Clock c;
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
{
window.close();
}
}
window.clear();
if (c.getElapsedTime().asMilliseconds() >= 16)
{
c.restart();
}
window.display();
}
return 0;
}
When I compile the code I get "undefined reference to `vtable for GT::NormalParticle"
I am new to the whole idea of inheritances so I am probably missing something
(also first time posting to the forum)