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 ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    6

    Main variable available to all classes

    Hi.

    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?

    thanks.

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    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
    Posts
    6
    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, 01:16 PM
  2. Make a Variable Available to All Classes?
    By Grantyt3 in forum C# Programming
    Replies: 3
    Last Post: 04-02-2006, 10: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 Cprogramming.com
    Replies: 15
    Last Post: 05-29-2002, 08:08 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21