Results 1 to 3 of 3

Thread: Truly Global

  1. #1

    Thread Starter
    Fanatic Member sql_lall's Avatar
    Join Date
    Jul 2002
    Location
    Up Above (i.e. AUS)
    Posts
    571

    Talking Truly Global

    Hello!

    I was just wondering something that's kinda bugging me....

    You see, i want certain variables to be able to be accessed from numerous .cpp and .h files... (all in the usual Class XXX.cpp, XXX.h pairings)

    At the momemt, the easiest and cleanest thing so far i've found is to make a GLOBAL class, fill it with all the variables that i want, and then have up the top of the files:
    Code:
    #include "glob.h"
    extern GLOB prjGlobals;
    or something similar...is there an eaier way?
    sql_lall

  2. #2
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Truly Global

    Originally posted by sql_lall

    or something similar...is there an eaier way?
    Probably not.

    You may want to re-think your design though. I doubt you absolutely need those global variables.

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    There's a few way of providing global information to the app. The most common and probably cleanest is to have an application class, implemented as a singleton, available from everywhere through a static accessor method, that provides the global data.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width