Originally posted by: DaveSimmons
the variable also needs to appear in one of your cpp code files, not just the header. Look up "extern" in the index of your textbook.
I had this thing typed up, and then realized from the next message that he's using managed C++, which I don't have a lot of experience with (I do C# these days). But I'll post this anyway. Might help someone. In C/C++ (compiled, unmanaged) a variable declared as
bool fooBar;
Is both a declaration and a definition. The presence of that declaration in sample.h, which is included in sample.cpp, means that when sample.cpp is compiled the declaration is present in the translation unit, and doesn't require any additional definition to be accessible in that unit.
Since this variable isn't marked static, it has external linkage. If the project contains another module sample2.cpp that also includes sample.h, then a duplicate symbol error will occur at link time. This is why headers are, by convention, typically limited to declarations only (classes, structs, enums, typedefs). You usually don't want any definitions in them, because they are included in multiple places.
What is sometimes done is to declare a variable at module scope, say in sample.cpp, and then in another header have an extern declaration that simply introduces a declaration into scope within the current translation unit, without creating a definition (i.e. no storage). The linker will fix up the reference at link time, as long as it is defined non-statically in some other module that is being linked.
sample.cpp
bool fooBar;
anotherh.h
extern bool fooBar;
Needless to say, not a great practice

.
As an aside, the syntactic distinction between declarations and definitions is one of the hardest things for a new programmer to get right in C or C++, and is one of the biggest sources of link-time frustration. Their absence is also one of the things I like the most about C#.