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

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.

 

Posted Date: 3/19/2013 8:49:21 AM | Location : United States







Related Discussions:- After p = new fred[n], how does the compiler know about , Assignment Help, Ask Question on After p = new fred[n], how does the compiler know about , Get Answer, Expert's Help, After p = new fred[n], how does the compiler know about Discussions

Write discussion on After p = new fred[n], how does the compiler know about
Your posts are moderated
Related Questions
#question write a prog c & cpp


C program to print fibonacci series: int fibo(long int); void main() {                 long int a=0,n;                 printf ("how many terms\n");

Pos Console CPP Unit Testing Project Description: Do the CPPUnit Testing for the project. Have all the functions done. Skills required are Android, C Programming, C++ Prog

A string S is said to be "Super ASCII", if it contains the character frequency equal to their ascii values. String will contain only lower case alphabets (''''a''''-''''z'''') and


Problem 1 What is the difference between function declaration and function definition? 2 Write a recursive function to find sum of even numbers from 2 to 10. 3 List some

What is inheritance? Class, the vehicle, which is used to execute object-oriented concepts in C++, has given a new dimension to this idea of reusability. Many vendors now offer

steric in square