Global variables.. how bad?

This is a discussion on Global variables.. how bad? within the C++ Programming forums, part of the General Programming Boards category; You can use singletons, which are basically objects with a static member that mimics global variables....

  1. #16
    Registered User
    Join Date
    Aug 2003
    Posts
    470
    You can use singletons, which are basically objects with a static member that mimics global variables.

  2. #17
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    bump bump bump
    That's against the rules, you know.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  3. #18
    Registered User
    Join Date
    Oct 2003
    Posts
    83
    it is? oops. i'll read over the rules again. but while your here couldn't you look at my code?
    Last edited by punkrockguy318; 11-30-2003 at 08:04 AM.

  4. #19
    Registered User
    Join Date
    Jul 2003
    Posts
    12
    I've done games and programs with a Settings class with all necessary static variables for global use. But I have a question for you all, should I make an Settings object global, or is it better to pass it along to all classes that need it?

  5. #20
    Registered User
    Join Date
    Aug 2003
    Posts
    470
    I think it's better to create the settings class as a Singleton. Here's some information if your interested. http://gethelp.devx.com/techtips/cpp.../10min0200.asp

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 08-06-2008, 10:59 AM
  2. Avoiding Global variables
    By csonx_p in forum Windows Programming
    Replies: 32
    Last Post: 05-19-2008, 01:17 AM
  3. global variables in qbasic
    By Geo-Fry in forum Game Programming
    Replies: 10
    Last Post: 10-09-2003, 08:53 AM
  4. global variables - okay sometimes...?
    By MadHatter in forum C++ Programming
    Replies: 21
    Last Post: 01-21-2003, 04:23 PM
  5. C global variables
    By Dohojar in forum C Programming
    Replies: 18
    Last Post: 02-25-2002, 12:00 PM

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