I am creating a class that takes an unknown amount of objects and then draws them on the screen.
I'm trying to utilize templates but don't know how they work, and every source I've read so far shows a different way of writing it.
.cpp
// file composite.cpp
#include <SFML/Graphics.hpp>
#include "composite.h"
#include "copy.h"
template<typename arguments> class drawable
composite<arguments>::composite() {
drawable<arguments> shape;
}
void draw(sf::RenderWindow & window, sf::Vector2f position) {
for (int i = 0; i < 10; ++i) {
//if (parts[i] != NULL) {
// Draw part
//parts[i].draw();
//}
}
}
.hpp
// file composite.hpp
#ifndef _COMPOSITE_HPP
#define _COMPOSITE_HPP
#include <SFML/Graphics.hpp>
#include "drawable.h"
#include "copy.h"
template<typename arguments>
class composite : public drawable {
public:
composite<arguments>::composite();
void draw(sf::RenderWindow & window, sf::Vector2f position) {};
private:
copy *shape1, *shape2, *shape3;
copy *parts[10];
};
#endif
Right now I'm getting error's like "error C2514: 'composite' : class has no constructors", but I'm pretty sure I've made a constructor for that class.
What am I doing wrong?