What is a statement?
How is memory usually accessed in c++?
Through objects. Direct memory access is discouraged.
What is the difference between definition and initialisation?
Definition creates a space in memory for the variable according to its data type
Initialisation assigns a value to the variable at the moment of its creation
What are the different forms of initialisation?
traditional:
- copy initilization: initial value after equal sign => int a = 5;
- direct initialisation: initial value in parenthesis => int a (5);
modern:
- direct-list-initialisation: initial value in braces => int a {7};
- value-initialisation: empty braces => int a {};
With default initialisation, what is the value of the variable?
The variable is not initialised and contains garbage value
What is the modern way to initialise variable in c++?
Direct list initialization, the use of curly braces
What is disallowed with direct list initialisation?
Narrowing conversion are disallowed and the compiled is required to produce and error
What is the value of a variable after value initialisation?
The variable is initialised to the equivalent of zero for its data type
What variable attribute allows us to not get a warning if a variable is unused?
[[maybe_unused]]