What is a variable in C++?
A variable in C++ is an object that has a name.
What is Definition of a variable?
A special kind of declaration statement that is used to create a variable
What is Instantiation of a variable?
A piece of memory from RAM that is set aside when the CPU executes a statement that creates a variable. Whenever the program sees that variable in an expression or statement, it knows to look in the memory location set aside for the variable.
What is the difference between an l-value and an r-value?
An l-value is a value that has a persistent address (in memory) whereas an r-value refers to values that are not associated with a persistent memory address. r-values are generally temporary in nature and are discarded at the end of the statement in which they occur.
In addition, l-values are the only values that can be on the left side of an assignment statement.
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 (through initialization or assignment) is called an uninitialized variable . In C++ when a variable is assigned a memory location by the compiler the default value of the variable is whatever value already happens to be in the memory location and using the variable will result in undefined behavior (i.e. you cannot predict what will happen when you use the uninitialized variable.
What is undefined behaviour?
Undefined behavior is the result of executing code whose behavior is not well defined by the language. For example, C++ doesnât have any rules determining what happens if you use the value of a variable that has not been given a known value. Consequently, if you actually do this, undefined behavior will result.
#1 3
#2 3
#3 6
#4 3
#5 undefined behavior â canât determine in advance what the value will be
#6 What is undefined behaviour?
Undefined behavior is the result of executing code whose behavior is not well defined by the language. For example, C++ doesnât have any rules determining what happens if you use the value of a variable that has not been given a known value. Consequently, if you actually do this, undefined behavior will result (e.g. in the case of an uninitialized variable you wonât know in advance what the output value of the variable will be).