-3

I have to build a videogame with SDL for my end year proyect. However I'm somewhat lost about how and when to use classes.

T tried to include a variable type struct inside a class but I can't manage to do it, maybe Position should be a class instead of a struct? Here's my code:

struct Position{
    int x,y;
};

class Object{
    private:
        Position pos;
        Position speed;
        int tipe;
    public:
        Objeto(int,int);
        Objeto();
        ~Objeto(); // DESTROY
};

When I try to do this I get error: 'class Object' has no member named 'x' How can I include the struct in the object?

lisovaccaro
  • 32,502
  • 98
  • 258
  • 410

1 Answers1

5

From your error, I think you are trying to use

Objeto.x

instead of

Objeto.pos.x
Lord Zsolt
  • 6,492
  • 9
  • 46
  • 76