Having some trouble with using the extern type.Here is how I have it layed out:
//example header file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
enum colours {Red,Blue,Green,Alpha};
extern colours colour_Type;
class example
{
public:
void Foo() {
if (colour_Type == Red) {
//do stuff set a breakpoint
}
elseif (colour_Type ==Blue) {
// do stuff set a breakpoint
}
}
};
Above shows usuage of the extern enum type 'colour_Type'. I get the following error: fatal error LNK1120: 1 unresolved externals
Now if I comment out the usuage of the enum type 'colour_Type' I get no error. However, I need to be able to decalre it and use it as extern. In order to reference it in main without including the whole example.h file. Possible? Yes! But how?
When I try and declare it in main (and as I have explained without including the example.h file)
Are you sure this is not possible without including the header?
It is possible. Sometimes you may decide not to include a header in order to decrease the compilation dependencies. (This would in turn decrease the build time.)
In this case, you can simply act on behalf of the preprocessor and paste the contents of the header everywhere it is included. (Generally though, this would not make the build shorter, as to what I was referring earlier.)