[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppLocal
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppLocal
(C++) Local
A variable that has a small scope. The opposite of a global variable (it is adviced to minimize global data [1-4]).int a = 10; //Global 'a' int main(int argc, char* argv[]) { int a = 0; //Local 'a' assert(a==0); assert(::a==10); //Use scope operator to get global 'a' return 0; }
- include <iostream>
- include <assert>
Topic links
- #include
- scope operator'::'
- argc
- argv
- assert
- char
- for
- #include
- int
- iostream
- main
- return
- scope operator'::'
References
- 1) Herb Sutter,Andrei Alexandrescu. C++ coding standards: 101 rules, guidelines, and best practices. ISBN: 0-32-111358-6. Chapter 10: 'Minimize global and shared data'.
- 2) Bjarne Stroustrup. The C++ Programming Language (3rd edition).ISBN: 0-201-88954-4. Chapter 1.8.2.a: 'Don't use global data (use members)'
- 3) Jarrod Hollingworth, Bob Swart, Mark Cashman, Paul Gustavson. Sams C++ Builder 6 Developer's Guide. ISBN: 0-672-32480-6. Chapter 3: 'Avoid using global variables'
- 4) Jesse Liberty. Sams teach yourself C++ in 24 hours. ISBN: 0-672-32224-2. Hour 3, paragraph 'Global variables': 'In C++, global variables because they can create very confusing code that is hard to maintain.'
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
