Variables

closed account (LN7oGNh0)
Okay, I got confused on variables.

1. What does declaring a variable mean?

2. What does identifying a variable mean?

3. How do you display a variable?

Thanks in advance.
1. It means you state that a variable with a certain name exists and it has a certain type, but you don't know what value it holds yet until you see the definition. (Declaration comes before Definition).

This is a declaration:
extern int MyIntVariable;
You don't normally use declarations of variables, though - they're used for global variables, which you should not have any of.

This is a definition:
int MyIntVariable = 0;

2. What do you mean? In what context? If you meant "What is an identifier", the identifier is the name of the variable (e.g. MyIntVariable).

3. You could print it to the console with std::cout << MyIntVariable << std::endl; just like you display anything else.
Last edited on
closed account (LN7oGNh0)
Thank you very much.
Topic archived. No new replies allowed.