been playing around with sfml and game game programming for a while, but i am "expected an expression"

here is my code .h file

    #include <SFML\Graphics.hpp>

    using namespace std;

    class TileSet
    {
    public:
    TileSet(int firstTile, int tileWidth, int Tileheight, string filename );
    sf::Texture* GetTileSet() const;
    int FirstTileNo();
    int TilesCount();

    private:
    sf::Texture tileset;
    int firstTileNo;
    int tilesCount;
    };

.cpp file

    #include "TileSet.h"

    TileSet::TileSet(int firstTile, int tileWidth, int tileHeight,
             string filename):firstTileNo(firstTile)
    {
    tileset.loadFromFile(filename);

    int tilesInWidth = tileset.getSize().x / tileWidth;
    int tilesInHeight = tileset.getSize().y / tileHeight;

    tilesCount = tilesInWidth * tilesInHeight;
    }

    sf::Texture* TileSet::GetTileSet() const
    {
    return tileset* ;
    }

the error points to the "return tileset*;" statement

有帮助吗?

解决方案

Wimmel is correct in his comment. You need to change tileset*; to &tileset; This will return a pointer to your tileset

EDIT: should be return &(const sf::Texture)tileset; but I'm not sure if that's what you want. I'm not a C++ expert and const correctness is not my strong suit, so I might do some more research on const correctness just to make sure that's what you really want or not.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top