'multiple definition of variable'-error

Started by
11 comments, last by branhield 20 years, 5 months ago
hm ok

thx guys
Advertisement
I think you should put the variables in main.cpp and use the extern keyword in display.cpp

like this:
main.cpp
--------
BITMAP *ground;
BITMAP *grass;

PALETTE ground_pal;
PALETTE grass_pal;

int world[5][5] = { 1, 0, 0, 0, 0,
0, 1, 0, 0, 0,
0, 0, 1, 0, 0,
0, 0, 0, 1, 0,
0, 0, 0, 0, 1 };

display.cpp
-----------
extern BITMAP *ground;
extern BITMAP *grass;
extern PALETTE ground_pal;
// etc.

hope that helps

Matt
Matt
Or just not use globals, they''re not necessary. But that''s a flame war in itself! :-)

Why you shouldn''t use iostream.h - ever! | A Good free online C++ book

This topic is closed to new replies.

Advertisement