Thread: Main variable available to all classes

  1. #1
    Registered User
    Join Date
    Nov 2005

    Main variable available to all classes


    My main code has the statement:

    #define dimensions 2

    How is it possible (without passing the value to each object as it is created) to make this value available to all classes that are used within thie main code?


  2. #2
    Registered User
    Join Date
    Jan 2005
    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.

  3. #3
    Registered User
    Join Date
    Nov 2005
    OK thanks for your help

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. " void main() is evil. Use int main(). "
    By Brw_Abhi in forum C++ Programming
    Replies: 7
    Last Post: 06-06-2007, 12:16 PM
  2. Make a Variable Available to All Classes?
    By Grantyt3 in forum C# Programming
    Replies: 3
    Last Post: 04-02-2006, 09:28 AM
  3. About classes and HINSTANCE variable to Main
    By conright in forum Windows Programming
    Replies: 2
    Last Post: 01-01-2003, 08:00 PM
  4. void main
    By Shadow in forum A Brief History of
    Replies: 15
    Last Post: 05-29-2002, 07:08 PM