Code of sfml book and the actual tutorial is different?
Im on chapter and i got one error where VS can is saying the my TextureHolder is undefined. I cant figure out how to solve it. I declare all the header on my aircraft.h
But when i look on the code of sfml book there is this ResourceIdentifiers. Its not event mentioned in the book
Here is my whole code
#include "Entity.h"
#include "ResourceHolder.h"
class Aircraft : public Entity
{
public:
enum class Type{
Eagle,
Raptor
};
Aircraft(Type type, const this_undefined& textures); <--------- this is the error; its undefined
virtual void drawCurrent(sf::RenderTarget &target, sf::RenderStates states) const;
private:
Type mType;
sf::Sprite mSprite;
};
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include<assert.h>
#include<map>
#include <iostream>
#include <memory>
using namespace std;
namespace Textures{
enum class Type{
Eagle,
Raptor
};
}
template<typename Resource, typename Identifier>
class ResourceHolder{
public:
void load(Identifier id, const std::string &filename);
template<typename Parameter>
void load(Identifier id, const std::string &filename, const Parameter &secondParam);
Resource &get(Identifier id);
const Resource &get(Identifier id) const;
typedef ResourceHolder<sf::Texture, Textures::Type> this_undenfined;
private:
std::map<Identifier, std::unique_ptr<Resource>> mResourceMap;
};
This is the code im following on the book. But i dont know why the "this_undefined" variable is undefined in my IDE
NOTE: I change it to the word "this_undefined" to highlight the error
Im stuck. I tried all that i know. I declare the header file on aircraft.h to be able to get the variable of ResourceHolder.
Another thing is that the code from the link has also this
namespace sf
{
class Texture;
}
namespace Textures
{
enum ID
{
Eagle,
Raptor,
Desert,
};
}
// Forward declaration and a few type definitions
template <typename Resource, typename Identifier>
class ResourceHolder;
typedef ResourceHolder<sf::Texture, Textures::ID> TextureHolder;
which for me doesnt make any sense as it could be declare on resourceHolder alone. So why bother creating another file?
I declare the header file on aircraft.h to be able to get the variable of ResourceHolder.
Please express yourself clearly, I have no idea what you mean. Make sure you're using the correct terms and illustrate the problem with code, if necessary.
What i mean by this is this
#include "Entity.h"
#include "ResourceHolder.h"
Its on the Aircraft class
class Aircraft : public Entity
{
public:
enum class Type{
Eagle,
Raptor
};
Aircraft(Type type, const this_undefined& textures);
virtual void drawCurrent(sf::RenderTarget &target, sf::RenderStates states) const;
private:
Type mType;
sf::Sprite mSprite;
};
which i was expecting that i could get the this_undefined variable without any errors.