[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
mouse » Obfuscator » BeginnersGuideToPHP » DirectX » VisualCpp » Compaq » QBasicFAQ » VBNetFAQ » newcsharpdotentlink » realnumbers » CppVariable
Don't declare a variable until you have a value to initialize it with [1].
In the code example below, there are two variables, number and i (actually argc and argv are also variables, but see their pages what they are)
The variable number has the entire main function as its scope. The variable only has the for loop as its scope.
There are many different data types of variables.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
mouse » Obfuscator » BeginnersGuideToPHP » DirectX » VisualCpp » Compaq » QBasicFAQ » VBNetFAQ » newcsharpdotentlink » realnumbers » CppVariable
(C++) Variable
A variable is something to store data in.Don't declare a variable until you have a value to initialize it with [1].
In the code example below, there are two variables, number and i (actually argc and argv are also variables, but see their pages what they are)
int main() { int number = 0; for (int i = 0; i<10; ++i) { number+=i; std::cout << i << " : " << number << std::endl; } }
- include <iostream>
The variable number has the entire main function as its scope. The variable only has the for loop as its scope.
There are many different data types of variables.
Topic links
'Variable' links
Reference
- 1) Bjarne Stroustrup. The C++ Programming Language (3rd edition).ISBN: 0-201-88954-4 6.5.10: 'Don't declare a variable until you have a value to initialize it with'.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
