After p = new fred[n], how does the compiler know about , C/C++ Programming

Assignment Help:

After p = new Fred[n], how does the compiler know about n objects to be destructed throughout delete[] p?

A:  The run-time system hold the number of objects, n, somewhere where it may be retrieved if you know the pointer, p only. There are two famous techniques that do this. Both of these technique are in use trhough commercial-grade compilers, both have tradeoffs, & neither is perfect. These techniques are following:

Over-allocate the array & put n only to the left of the first Fred object. Employ an associative array along with p as the key and n as the value.

 


Related Discussions:- After p = new fred[n], how does the compiler know about

#padovan string in c, #write a program that counts the number of occurances...

#write a program that counts the number of occurances of the string in the n-th padovan string p(n)

Car rental system, complex coding with structure and file handling

complex coding with structure and file handling

Develop custom mql4 code, Develop Custom Mql4 Code/Fxdreema block Projec...

Develop Custom Mql4 Code/Fxdreema block Project Description: I need the subsequent code written in mql4 and integrated as custom block(s) in fxdreema: for each trade: C

Create a minimum of fifteen functions, Purpose For this assignment you ...

Purpose For this assignment you will need to create either a function list or a record series for a CRCRS. Instructions Note: Complete only one of the two assignment op

Described the order that objects in an array is destructed?, Described the ...

Described the order that objects in an array is destructed?

Program that controls the lcd display, Objective:  Construct a C program...

Objective:  Construct a C program that controls the LCD display, and is capable of displaying strings.  Add functions to the C program that allows more control over the display.

How to define a structure, How to Define a Structure? Structure declara...

How to Define a Structure? Structure declarations are rather more complicated than array declarations, ever since a structure must be defined in terms of its individual members

Assignment question, : Write a program that prompts the user to enter five...

: Write a program that prompts the user to enter five digit positive numbers. The program then outputs the digits of the number one digit per line. Eg if the user enters 32456, th

Why should i employ new instead of truthful old malloc()?, Why should I emp...

Why should I employ new instead of truthful old malloc()? A: Constructors/destructors, type safety, overridability. Constructors/destructors: unlike malloc(sizeof(Fred)), new

Refactoring, Refactoring Project Description: TASK 1 - DESIGN ALGORIT...

Refactoring Project Description: TASK 1 - DESIGN ALGORITHM You are required to design a suitable solution algorithm by using structured chart, pseudocode or flowchart. Thi

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd