C How To Program Plus Mylab Programming With Pearson Etext -- Access Card Package (8th Edition)
8th Edition
ISBN: 9780134227023
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
Draw a memory diagram for the following code
Do any or all of the declaration statements result in RAM being reserved?
Explain how to examine the memory address of the pointer directed to.
Chapter 18 Solutions
C How To Program Plus Mylab Programming With Pearson Etext -- Access Card Package (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
- Fill in blank In xv6, function ----------- can be invoked in order to obtain a pointer to the PCB of the current process.arrow_forward76. What are the values of the following expressions:2**(3**2) (2**3)**2 2**3**2 a. 64, 512, 64 b. 64, 64, 64 c. 512, 512, 512 d. 512, 64, 512arrow_forwardExercise 1: Memory Allocation in C a) Write a C program which dynamically allocates memory to define an integer 5 x 5 matrix initialized to zero by using the calloc function. Do not forget to free the memory in the end of your program. b) What happens if you attempt to print your matrix before and after freeing memory?arrow_forward
- Write a program in C++ of how to use two-dimensional dynamic arrays. Follow the instruction below; - Declare the function of fill and print - Create main function and include your information details - Declares 'board' to be a pointer to a pointer of type int - Declare the 'rows' and 'columns' as integer variables - Prompt user to enter the number of rows and colums - Get the user input of rows and colums - Create the rows of board - Create the columns of board - Insert elements into board - Print the elements of boardarrow_forward-Please I need a complete code -Write a assembly code - using 16 bit register - please in code use MACRO -show test cases in emuo8086 Q2. - - - Write assembly code to perform the following computations: Calculate the sum of elements in the array, and the occurrences of each element in the array and store the results in the occurrences array. Check if the sum is divisible by 2. If the sum is divisible by 2, print “even”, otherwise, print “odd” The code should declare an array of 10 elements and the user should enter each value from the keyboard. Assume the user enters digits between 0 and 9 only. The results should be printed on the screenarrow_forward44.____Write a code in CPP that performs the sum operation on array of 10 elements. Elements of array should be taken from user at run time. In order to point to the next position of array you need to use pointer arithmetic.?arrow_forward
- Compilation Techniques a. Translate the three-address statement, the following expression: n = f((x+2), y) – 5; b. If A is an array of integers with width = 4; Translate with a three-address statement, the following expression: x = a[i] + 2arrow_forwardPerform the given task.arrow_forwardCan you provide a C++ code to include the a memory table for each function bot a and b and also int (main). Please show C++ codearrow_forward
- Please implement the following function using loop Please write in MIPS Assembly languagearrow_forwardby using c++. How can I solve this? Kindly, no class, linked list, and pointers shall be used in this program. Kindly use only SELECTION, ITERATION, INPUT, AND OUTPUT, FUNCTION, ARRAY, AND STRING ONLY.arrow_forwardExplain any memory bugs in the code.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrSystems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
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