|
-
February 25th, 2007, 12:30 PM
#1
C++ Global Vars help
OK, I want to make an instance of a class global for an entire multi-file project... If it helps, it is an instance of a game class for a game. How do I do this?
Right now, I've got a file called "headers.h" which declares the actual class as so:
Code:
static CardGame game(640, 480, 32);
And files that need this variable "game" include headers.h ...
However, I'm convinced that this is somewhat improper, because I'm getting two instances of CardGame that are both named "game".
For some reason, this does not generate a compiler error, but I have proved that there's more than one floating around by putting an output statement into the CardGame constructor...
Anyhoo, should I declare that in main instead? I want this variable to have scope throughout the entire project.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|