C++ language
1.
Programs with memory leaks
a |
should be executed in a secure environment to prevent theft of data by hackers. |
|
b |
will eventually crash if allowed to execute for long periods of time. |
|
c |
should be compiled with a special compiler that detects and flags the memory leaks. |
|
d |
should be executed under an operating system that can dynamically plug the leaks. |
|
e |
none of these. |
2. An lvalue is
a |
a value of type long. |
|
b |
a memory location that is associated with a name that can be used by different parts of the program to access the memory location. |
|
c |
An expression denoting a value that appears as the left operand of a binary operator. |
|
d |
a value of type long returned from a function. |
|
e |
none of these |
3. When overloading the operator ++, ________ is used to distinguish preincrement from postincrement.
a |
a parameterless data type |
|
b |
the keyword void |
|
c |
a dummy integer parameter |
|
d |
the placeholder [ ] |
|
e |
none of these |
4. True/False: If a unique pointer ( unique_ptr) p points to a block of memory, a second unique pointer can be made to point to the same block of memory by using the library function move(p).
a. True
b. False
Question 1:
Programs with memory leaks
Ans: will
eventually crash if allowed to execute for long periods of
time.
If we have a program with memory leaks, when we allowed running for a very long period of time, It eventually consumes all the resources and finally gets crashed.
Question 2:
An lvalue is
Ans: a memory
location that is associated with a name that can be used by
different parts of the program to access the memory
location.
An lvalue is a left-hand side value, which holds the memory
location with the name. Consider the example:
int variable;
variable=4;
Here, Variable is an lvalue that holds the memory location with a
name and further can be accessed by different parts of the
program.
Question 3:
When overloading the operator ++, ________ is used to distinguish
preincrement from postincrement.
Ans: the
placeholder [ ]
We use the placeholder [ ], whenever we want to overload the operator ++ so that it can be distinguished pre-increment from post-increment.
Question 4:
True/False: If a unique pointer ( unique_ptr) p points to a block
of memory, a second unique pointer can be made to point to the same
block of memory by using the library function move(p).
Ans: True
A unique pointer is a pointer that points to a specific memory block and there is one only such pointer which points to that locations. so we can copy that pointer but we can able to use the library function move(p) in order to make the pointer point to some other location.
(Feel free to drop me a comment, If you need any help)
Hope this Helps!!!
Please upvote as well, If you got the answer?
If not please comment, I will Help you with that...
Get Answers For Free
Most questions answered within 1 hours.