Main variable available to all classes

This is a discussion on Main variable available to all classes within the C++ Programming forums, part of the General Programming Boards category; Hi.
My main code has the statement:
#define dimensions 2
How is it possible (without passing the value to each ...

This isn't a variable it's a pre processor define. It may be used anywhere in your source file below where you defined it. You should place these in a header file which would need to be included by all source files that use them.