When the command new fails it shuts down the program returns a NULL produces a s
ID: 3855293 • Letter: W
Question
When the command new fails it shuts down the program returns a NULL produces a seg fault throws a bad_alloc exception What best describes the steps that are part of the overloaded assignment? check for self-assignment, delete the existing array, allocate a new array of the same capacity as that in the other object, copy the data from that array, make capacity and used the same as in the other object make used the same as the used in the other object, make the capacity the same as the other object, make the pointer the same as the other object. allocate a bigger array, make capacity larger, make the new array point at the array in the other object, copy the various for used and capacity delete the array in the other object, copy all the data from that object to the existing array in the current object, make all the pointers point at the same thing and make sure that used and capacity are the same. According to Mr. Dolan, a pointer should be defined as a variable capable of holding an address. A- > operator an address in the computer's memory a variable that remembers the current array index.Explanation / Answer
Answers:
1.D
If you don't use nothrow then it can be throws an std::bad_alloc exception
let us see an example how it be works
Example:
try
{
Node* lisnod = new Node(val);
//ensured to be a decent alloc in the event that we reach here
//in the event that it was a terrible alloc, we go to our catch
return true;
}
catch(std::bad_alloc& exc)
{
return false;
}
2.A
in c++
the assignment operator should be overloaded with self assignment check
3.A
A pointer is a variable whose esteem is the address of another variable, i.e., coordinate address of the memory area. Like any factor or consistent, you should pronounce a pointer before utilizing it to store any factor address. The general type of a pointer variable assertion is
type *var-name;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.