C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
thumb_up100%
Chapter 18, Problem 18.6E
(Memory Allocation and Deallocation Operators) Compare and contrast dynamic memory allocation and deallocation operators new, new [], delete and delete []:
Expert Solution & Answer
Program Plan Intro
To compare and contrast dynamic memory allocation and deallocation operators new, new[], delete and delete[].
Explanation of Solution
The following table shows the differences.
S. No. | New | Delete | New[] | Delete[] |
1. | Dynamically allocates memory for a variable or object. | Dynamically de-allocates memory for a variable or object. | Dynamically allocates memory for an array. | Dynamically de-allocates memory for an array. |
2. | Arguments passed to initialize class constructor | No arguments needed to be passed to call destructor | Arguments passed to initialize array size (bytes). | No arguments needed to be passed to call destructor. |
3. | Memory de-allocation must be done using delete operator. | Memory allocation must be done using new operator. | Memory deallocation must be done using delete[] operator. | Memory allocation must be done using new[] operator. |
4. | Returns address of allocated object. | Returns void() and sets memory to NULL. | Returns address of first element of allocated array. | Returns void() and sets all memory to NULL. |
5. | For example, int *xPtr; xPtr= new int; | For example, delete xPtr; | For example, int *xPtr; xPtr= new int[10]; | For example, Delete[] xptr; |
Want to see more full solutions like this?
Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
15.
The only way to access data stored in heap memory is through
pointer variables
malloc ()
allocation tables
а.
b.
С.
d.
a buffer memory
(c) Does an integer pointer store an integer itself or something else?
(d) What is the purpose of pointers? What do they allow us to do? What would happen if we
didn't have pointers?
Segmentation: Select all of the following statements that are true.
In segmentation, a logical address always has a length of 32 bit.
In order to translate logical into physical addresses, the memory management
unit uses the segment part of the logical address to determine the start address
in the segment table and adds the offset to this to get the physical address.
In segmentation, the logical address consists of a segment part and an offset.
The segment length is limited by the maximum possible segment number.
When applying segmentation, processes are only allowed to access the memory
within their segments.
Segments can be assigned access rights and privilege levels.
Chapter 18 Solutions
C How to Program (8th Edition)
Ch. 18 - (Memory Allocation and Deallocation Operators)...Ch. 18 - (Overloading the Parentheses Operator) One nice...Ch. 18 - (Complex Class) Consider class Complex shown in...Ch. 18 - (HugeInt Class) A machine with 32-bit integers can...Ch. 18 - (RationalNumber Class) Create a class...Ch. 18 - Prob. 18.11E
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
(Adapted from Barwise and Etchemendy (1993).) Given the following, can you prove that the unicorn is mythical? ...
Artificial Intelligence: A Modern Approach
What happens if you try to compile the TIcketMachine class with the following version of refundBalance? publici...
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
The ________ object is assumed to exist and it is not necessary to include it as an object when referring to it...
Web Development and Design Foundations with HTML5 (8th Edition)
What is pseudocode?
Starting Out with C++: Early Objects (9th Edition)
Describe the common components needed to create a Web-based application.
Modern Database Management
The file pie=full. hcl contains a copy of the PIPE HCL description, along with a declaration of the constant va...
Computer Systems: A Programmer's Perspective (3rd Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Refer to imagearrow_forwardLanguage:C Write the function that produces the largest and smallest elements of an integer array sent to it, in accordance with the main function below. (Access to array elements should be done according to offset-address increment notation.)Sample Run:Biggest : 23Smallest : 0Sample Main................................/*prototip*/int main(){int array[5]={23, 4, 2, 0, 8};int biggest;int smallest;bigSmallFind(.............................)printf("Biggest : %d \n", biggest);printf("Smallest : %d \n", smallest);return 0; }arrow_forwardComputer sciencearrow_forward
- COAL - Computer Organization and Assembly Languagearrow_forwardQUESTION 6 Which of the following is NOT true? (Choose all that apply) 01. None II. A dangling pointer is an allocated stack-dynamic pointer variable without any reference. III. Dangling pointers are harmful for the programs. OV. A program with memory leak is free from creating garbage.arrow_forwardMemory Management: Select all of the following statements that are true. The memory management unit (MMU) maps virtual to physical addresses. When using a single-partition allocation scheme, the main memory is divided into two partitions. The frame table that is applied in systems that use paging is a per-process data structure. Indirect relative addressing refers to an addressing scheme in which the memory address to be accessed is specified explicitly. Segmentation is a memory management approach in which memory areas (segments) allocated to processes are defined by their starting address (base) and length.arrow_forward
- Language: Java Write the function that produces the largest and smallest elements of an integer array sent to it, in accordance with themain function below. (Access to array elements should be done according to offset-address increment notation.)Sample Run:Biggest : 23Smallest : 0Sample Main................................/*prototip*/int main(){int array[5]={23, 4, 2, 0, 8};int biggest;int smallest;bigSmallFind(.............................)printf("Biggest : %d \n", biggest);printf("Smallest : %d \n", smallest);return 0;}arrow_forward(python) 14. Based on the following Sorted List, show the steps of a Binary Search if the search key was -5: Enter the index value for the left, right and comparison. Enter one of the following for the Result answers: Left, Right, Found, Not Found. If there is no value needed in a location, put N/A [ -34, -23, -11, -5, 1, 3, 7, 11, 14, 19, 20, 25, 33, 42 ]arrow_forwardThere is more than one answer find them pleasearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
1.1 Arrays in Data Structure | Declaration, Initialization, Memory representation; Author: Jenny's lectures CS/IT NET&JRF;https://www.youtube.com/watch?v=AT14lCXuMKI;License: Standard YouTube License, CC-BY
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License