1. What is a variable in C++?
A variable in C++ is an object that has a name.
2. What is Definition of a variable?
In order to create a variable, we use a special kind of declaration statement called a definition. For example: int x;
3. What is Instantiation of a variable?
The instantiation is a piece of memory from the RAM, which is set aside for the variable.
4. What is the difference between an l-value and an r-value?
an l-value is a value that has a persistent address. All variables in C++ are l-values. An r-value is a value which is not associated with a persistent memory address such as single numbers and expressions. R-values are discarded at the end of the statement in which they occur.
5. What is an uninitialized variable and what kind of behaviour can you expect from such a variable?
A variable that has not been given a known value is uninitialized.
6. What is undefined behavior?
Undefined behavior is the result of executing code whose behavior is not well defined by the language. For example, in C++ if you use a variable that has not been assigned a value, it can lead to undefined behavior because we do not know what is contained in the allocated address in memory. Undefined behavior can include: incorrect results, inconsistent results, a crash, incompatibility with certain compilers etc.