Advertisement

how to use global enum w/ multiple files?

Started by May 07, 2000 09:10 PM
1 comment, last by Possibility 24 years, 7 months ago
I have been using enums in my game, but I cant figure out how to make them accessible with multiple files. If I define the enum in main.cpp file, and then put it in the main.h file which all the other source files access, it says its being redefined. when I have say a global int, I declare it in the main.cpp and in the main.h like in main.cpp int variable = 10; amd then in main.h extern in variable; but how do i do the basic same thing with an enum? thanks for any help Possibility
just include the enum in a header file and then #include the header

note that the headers you write yourself should be #included with quotes

ie

#include "myheader.h"

and not brackets


adamm@san.rr.com
adamm@san.rr.com
Advertisement
oh yeah...
you need to use include guards to prevent it from being redefined

so say this is a sample header.. called myheader.h

you''d do something like this


#ifndef _MYHEADER_H
#define _MYHEADER_H

// the stuff for the include file

#endif

you want to do this with EVERY header file you write


adamm@san.rr.com
adamm@san.rr.com

This topic is closed to new replies.

Advertisement