1. What is a variable in C++?
A variable is a named region of memory that can be used to store values.
A variable defines the object with a variable name and assigns the data type associated with it in some space in computer memory.
2. What is Definition of a variable?
In order to create a variable, we use a special kind of declaration statement called a definition.
3. What is Instantiation of a variable?
When the program is run (called runtime), the variable will be instantiated. Instantiation means the object will be created and assigned a memory address. Variables must be instantiated before they can be used to store values. For the sake of example, letās say that variable x is instantiated at memory location 140. Whenever the program uses variable x, it will access the value in memory location 140. An instantiated object is sometimes called an instance.
4. What is the difference between an L-value and an r-value? l
L-valueā refers to a memory location that identifies an object. ār-valueā refers to the data value that is stored at some address in memory.
5. What is an uninitialized variable and what kind of behaviour can you expect from such a variable?
An uninitialized variable is a variable that has not been given a value by the program (generally through initialization or assignment). Using the value stored in an uninitialized variable will result in undefined behavior.
6. What is undefined behaviour?
Undefined behavior means when the program fails to compile, or it may execute incorrectly, either crashes or generates incorrect results, or when it may fortuitously do exactly what the programmer intended. Whenever the result of an executing program is unpredictable, it is said to have undefined behavior.