| | |
variables scope
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
•
•
how do i make it so that functions and procedures that are located in other files in the include statement have access to the global variables within main.cpp, thanks in advance.
main.cpp:
c++ Syntax (Toggle Plain Text)
... bool troublesWanted = true; bool IlikeBadDesign = true; ... int main() { ... } void Nil() {}
c++ Syntax (Toggle Plain Text)
#ifndef GLOBALS_H #define GLOBALS_H extern bool troublesWanted; extern bool IlikeBadDesign; void Nil(); #endif
c++ Syntax (Toggle Plain Text)
... #include "globals.h" void Void() { if (!troublesWanted) IlikeBadDesign = false; else Nil(); }
Last edited by ArkM; Jan 1st, 2009 at 7:46 pm.
![]() |
Similar Threads
- Tutorial: Understanding ASP classes (ASP)
- Problem passing variables to thread (Perl)
- require_once variables not available in function (PHP)
- Scope Problem (C++)
- external variables in a multifile program (C++)
- Urgent.....Dynamic Changes.... (JavaScript / DHTML / AJAX)
- C/C++: Dynamically Scoped Language (C++)
- stripping digits (C)
- problems with referring to class variables (Java)
Other Threads in the C++ Forum
- Previous Thread: quick simple question.
- Next Thread: need help reading from a file.
Views: 383 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays based beginner binary c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg search simple sort sorting spoonfeeding string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






