Declaring custom struct in vector array
I need abit of help creating a vector array which can hold references to the custom struct type.
It's proving tricky also as it is defined in a class.
//Code in header
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
struct TileSprite
{
std::string name;
std::string file;
unsigned short index;
public:
// Constructor to set values of new TileSprites
TileSprite(std::string name, std::string file, unsigned short index)
: name(name), file(file), index(index)
{
}
TileSprite() {};
};
std::vector< TileSprite > tileSprite; <-- This is giving a strange error
|
//Code creating instances of object
tileSprite.push_back(TileSprite("floor", "data/floor.jpg", 1));
I'm getting an error "Invalid use of member 'Attributes::tileSprite' in static member function."
I don't see why it wont work.
Compiles fine with me on Dev.
Topic archived. No new replies allowed.