struct WORLD
{
SDL_Surface *image;
int value;
int x, y;
};
Structure for use in multiple files
Hi all,
I have this structure:
and I NEED it in more then one source file(.cpp). how can I make 2 instances of this struct without the compiler telling me I am causin an error?
Thanks,
Joshua
put that struct into a .h file, then #include that .h file from your two .cpp files.
ok, I am sorry if I was unclear, but I am not a TOTAL newie to c++.
I offcourse put my struct into a header file, and I used
But when I include them into 2 source files(.cpp), I get the following error:
hero.cpp C:\WINDOWS\Desktop\Joshua\RPG\hero.o(.bss+0x0) multiple definition of `world'
I hope this is clearer,
Joshua
I offcourse put my struct into a header file, and I used
#ifndef _WORLD_H#define _WORLD_H#include <SDL/SDL_image.h>extern struct WORLD{ SDL_Surface *image; int value; int x, y;};WORLD world[40][30];#endif
But when I include them into 2 source files(.cpp), I get the following error:
hero.cpp C:\WINDOWS\Desktop\Joshua\RPG\hero.o(.bss+0x0) multiple definition of `world'
I hope this is clearer,
Joshua
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement