- Variable holds the address of memory where value is stored.
- We define a variable by specifying a value type of it.
- Instantiation of variable is the process of reserving a block of memory for that variable.
- L-values have permanent address, r-values address is not fixed and is usually discarded after use
- Uninitialized variable is a variable that is defined but not initialized or without assignment. The value of such variables is not set to 0 by default, so the compiler just takes the bits from variable address. We can expect randomness.
- Undefined behaviour occurs when programmer uses an undefined variable.
I have the same problem in macOs , if somebody has the same problem that code blocks keep crashing in your MacOs what I did is use the xcode app where you can compile c++ too.
What is a variable in C++?
A variable in c++ is an object that has a name.
What is Definition of a variable?
A variable is a piece of memory that has a name where we can assign different types of values after defined.
What is Instantiation of a variable?
The instantiation of a variable is the the process of initialize and define a variable in the same moment.
What is the difference between an l-value and an r-value?
The l-value is persistenly in memory and the r-value is only temporary and discarded after we use it.
What is an uninitialized variable and what kind of behaviour can you expect from such a variable?
An uninitialized variable is a variable that we did not give a value yet and different like javaScript is not has an undefined value , instead its value could be anything that is at that moment in that piece of memory. it has an unpredictable value.
What is undefined behaviour?
The undefined behavior is the value of an uniintialized variable.
-
An object is something that is a piece of memory that can be used to store values. The object itself is something with a name.
-
A definition of a variable is a defined variable. For example numbers that is not with decimals is called Integers or in coding on c++ it is defined “int”.
-
An instatiation of a variable is when the variable has been declared and then set aside in the memory for later uses.
-
L-value is a value that has a persistant adress like “x = 2”, the “x” is a L-value.
R-value is a value that is temporary. Like “x = y +2”, the value “2” is a R-value that is added to “y” that is a L-value which is summed up to another L-value “x”. -
It is a variable that has not been assigned a value yet like “int y”. Depending on which build you have on your compiler then it can by accident (you not knowing) pick up a value from the memory that you have not assigned that was there before.
-
It is when the program is running your code with uninitialized variables and gives us unexpected behaviours. Because the variable is undefined if it is not assigned something.
- A variable in C++ is a name for an object.
- Definition of an variable is a special kind of declaration statement. with a definition you name name and type of the variable.
- Instattiation is when a statement of the defintion gets executed by the cpu. During execution a puece of memory of the RAM will be set aside for the in the statement mentioned variable.
- l-values is every value that has a persistent adress in memory. An r-vlaue refers to values that are not associated with a persistent memory adress r values are generally temporary in nature and get discarded at the end of the statement in which they occur.
- An uninitialiized variable is an variable which didnt get assigned during definition. During a print out of an unitialized variable you can not know what is in the reserved memory of this variable and the printed out information can change with another print out.
6.undefined behaviour is the result if executing code whose behaviour is not well defined by the language,
What is a variable in C++?
- a named object
What is Definition of a variable? - declaration of a new object
What is Instantiation of a variable? - set some memory in RAM aside for the variable
What is the difference between an l-value and an r-value?
-l - value has a specific location in the memory
-r-value has no specific location
What is an uninitialized variable and what kind of behaviour can you expect from such a variable? - a variable without assigning the value for it
- the program may crash or giving out different results when we run it.
What is undefined behaviour? - running the program with code that not defined by the program language or using uninitialized variables.
What is a variable in C++?
- an object with an assigned name
What is Definition of a variable?
- an expression specifying the type of variable
What is Instantiation of a variable?
- setting a variable value in memory
What is the difference between an l-value and an r-value?
- l-value is persistent, while r-value is temporary, not associated with a persistent memory address
What is an uninitialized variable and what kind of behaviour can you expect from such a variable?
- a variable with no value assigned to it, the behaviour of the variable is unreliable as any random value in memory will become its value
What is undefined behaviour?
- results of executing code whose behavior is not well defined by the language
- A variable is an object that has a name.
- It is a way to assign the data type of a variable.
- It is a reservation of memory space
- an l value is the name of the address of memory while r value is the value itself
- Uninitialized variables are those who are not given a value, and when using this kind of variables the value of the variable will be garbage.
- It is the result of executing code whose behaviour is not well defined by the language.
-
A variable is a named piece of memory
-
When you inform the computer to reserve some memory space as a named variable you have defined it.
-
It is when you actually assign a value to the memory address of a variable.
-
l-values refer to a location in memory ( a memory address ), and r-values refer to values without a memory address.
-
An uninstantiated variable has not been assigned a value, as such it points to whatever it’s memory address contained prior to it being defined.
-
Undefined behavior arises from executing code that the language was not defined to support, normally resulting in expected execution.
-
What is a variable in C++?
A variable in C++ is simply an object that has a name assigned to it. -
What is Definition of a variable?
We understand by definition of a variable to its creation using a special kind of statement called declaration. -
What is Instantiation of a variable?
When the declaration statement is executed by the CPU, a piece of memory from RAM will be set aside to store the object. This is called instantiation. -
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).
The opposite of l-values are r-values (pronounced arr-values). An r-value refers to values that are not associated with a persistent memory address. -
What is an uninitialized variable and what kind of behavior 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. Using the values of uninitialized variables can lead to unexpected results because the values pointed by the variables a random data in memory. -
What is undefined behavior?
Undefined behavior is the result of executing code whose behavior is not well defined by the language.
Source: Learn C++
- It is a container that holds some value
- It is stored in memory and usually having some value assigned to it
- It is creating a memory location for this specific variable
- l-values are usually standing on a left side of an expression, and the are representing memory containers that can point to some data. R-values stand on the right side, and they get determined as values and get assigned to l-values on the left
- It is a variable, that doesn’t have anything assigned in this particular program, but sometimes a random value in memory is being assigned to it without us knowing it. I can expect only unexpected behaviour from this variable
- It is a behaviour, that can be changing every time I run the code - it is not consistent at all
Please Help !
can’t seem to Installing the IDE in my mac. every time i try to run code block this pop up
“compiler plugin must always be loaded for batch builds”
Ivan only showed how to instal on Windows but not mac. Am having a Difficult time and i can’t be able to move forward with study.
help appreciated.
1.What is a variable in C++?
A variable in C++ is simply an object that has a name.
2.What is a variable in C++?
Is a memory location or holding a value for an object
3.What is Instantiation of a variable?
Instantiation of a variable is setting a side a piece of memory from RAM for that 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 (in memory) and are the only values that can be on the left side of an assignment statement
while r-value refers to values that are not associated with a persistent memory address and are generally temporary in nature and 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?
An uninitialized variable is a variable that has not been given a known value (through initialization or assignment).
Uninitialized variables can lead to unexpected results.
6.What is undefined behaviour?
Undefined behavior is the result of executing code whose behavior is not well defined by the language ,like uninitialized variable
Hi!
I haven’t tried to install code::blocks, I think it said somewhere on the download page that the macOS version was quite old and could be unstable.
I read somewhere here on the forum that someone was using Xcode (you can download it from the Apple store for free). I’ve been using it for the first exercises, and so far am being able to catch up with Ivan’s steps.
Hope this helps, good luck with the course!
What is a variable in C++?
A variable is an object that has a name, to which is assigned some memory location.
What is Definition of a variable?
Definition of a variable is when we establish the nature of the variable and the value it will hold.
What is Instantiation of a variable?
Instantiation is what happens when a variable is defined and a piece of RAM memory is allocated to it.
What is the difference between an l-value and an r-value?
l-values are always variables and they represent a memory address. They’re on the left side of the assignment operator. On the other hand, r-values are the values assigned to the l-values, and will they will be evaluated to produce a value.
What is an uninitialized variable and what kind of behaviour can you expect from such a variable?
This is a variable which hasn’t been assigned a value, and because C++ doesn’t have any rules on how to deal with them, the results of using them are potentially unexpected and unpredictable, i.e., we’ll be facing an undefined behaviour.
What is undefined behaviour?
This will be the result of using an uninitialized variable.
What is a variable in C++?
it is an object that has a name
What is Definition of a variable?
object that has a name
What is Instantiation of a variable?
a piece of memory from RAM which is put aside
What is the difference between an l-value and an r-value?
r-value hasn’t got a persistent memory address
What is an uninitialized variable and what kind of behavior can you expect from such a variable?
it is a variable that has not been given a known value, so it will generate a random number
What is undefined behavior? it is the result of executing code whose behavior is not well defined by the language
Thank Filipe.
I was able to Access C++ through Xcode.
- In C++ variable is object with name
- By defining the variable we state what kind of values can be assigned to it.
- Instantiation is definition and assiggnement of value to the variable in 1 step.
- l-values
- in variable they are on the left side from the operator, have persistent address in computer memory, can be overwritten if new value is assigned to it
r-values
-on the right side from operator, they are not associated with persistent address in the memory, temporary values which are discarted at the end of the statement in which they are assigned.
- Uninitialized variable was not given a known value. The outcome can be random number.
- Undefined behaviour is result of execusion of the code, which is not properly defined by the computer language.
1 What is a variable in C++ ?
A variable provides us with named storage that our programs can manipulate.
2 What is Definition of a variable ?
A variable definition tells the compiler where and how much storage to create for the variable. A variable definition specifies a data type, and contains a list of one or more variables of that type.
3 What is Instantiation of a variable ?
When this statement is executed by the CPU, a piece of memory from RAM will be set aside (called instantiation). For the sake of example, let’s say that the variable x is assigned memory location 140. Whenever the program sees the variable x in an expression or statement, it knows that it should look in memory location 140 to get the value.
4 What is the difference between an l-value and an r-value ?
An l-value is a value that has a address in memory. Since all variables have addresses, all variables are l-values. The name l-value came about because l-values are the only values that can be on the left side of an assignment statement. When we do an assignment, the left hand side of the assignment operator must be an l-value like 5 = 6; will cause a compile error, because 5 is not an l-value. The value of 5 has no memory and thus nothing can be assigned to it. 5 means 5 and its value can not be reassigned. When an l-value has a value assigned to it, the current value at that memory address is overwritten. The opposite of l-values are r-values. An r-value refers to values that are not associated with a memory address. Examples of r-values are single numbers (such as 5, which evaluates to 5) and expressions (such as 2 + x, which evaluates to the value of variable x plus 2).
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 (through initialization or assignment) is called an uninitialized variable. In this case, the computer will assign some unused memory to x. It will then send the value residing in that memory location to std::cout, which will print the value. But what value will it print? The answer is “who knows!”, and the answer may change every time you run the program.
6 What is undefined behaviour ?
Undefined behavior occurs when the program implements code whose behavior is not well defined by the language. When code with undefined behavior is implemented, the program may exhibit unexpected results.
- In C++ a variable is a place in memory.
2.In C++ a variable is an object that has a name. - Instantiation is when a piece of RAM is set aside for the object.
- An l-value has a persistent address in memory. An r-value have no address and are discarded at the en of the statement.
5 An initialized variable is one that has not been assigned a value. The value will be what ever will be at that memory location. - Unpredictable code, not defined by the language.