1

I have this code:(BITMAPS is a free name)

class BITMAPS{
public:
    static ALLEGRO_BITMAP *cursor;

    static void load_bitmaps();
    static void unload_bitmaps();
};

and I'm trying to use it like this:(the lines with the errors)

line 9:   BITMAPS.load_bitmaps();
line 23:  BITMAPS.unload_bitmaps();
line 36:  BITMAPS.cursor;

but I'm getting errors like this:(the errors)

line 9 and 23:    syntax error : missing ';' before '.'
line 36:          token '.' is illegal after UDT 'BITMAPS'
line 36:          'BITMAPS' : illegal use of this type as an expression
line 36:          left of '.cursor' must have class/struct/union

what is the problem?

EDIT:

I've changed . to :: and now I'm getting this:

unresolved external symbol "public: static struct ALLEGRO_BITMAP * BITMAPS::cursor" (?cursor@BITMAPS@@2PAUALLEGRO_BITMAP@@A)

what is this mean?

MoonBun
  • 4,322
  • 3
  • 37
  • 69

1 Answers1

11

You need to use the Scope Resolution:: operator to refer to them, and not the syntax you are using.

BITMAPS::load_bitmaps();
BITMAPS::unload_bitmaps();
BITMAPS::cursor;

EDIT: To answer your updated Q

You just declared the static member cursor, You also need to define it,in your source(cpp) file.
like:

ALLEGRO_BITMAP* BITMAPS::cursor = 0;

Good Read:
what does it mean to have an undefined reference to a static-member?

Suggestion:
You should read a good C++ book.

Community
  • 1
  • 1
Alok Save
  • 202,538
  • 53
  • 430
  • 533