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
.Create a Csharp solution that will show a maze in the user interface and will show a mouse walking through the maze attempting to locate the exit door (the cheese).

A palindrome is a string that reads the same from the both the ends. Given a string S convert it to a palindrome by doing character replacement. Your takes is to convert S to palin

Problem 1. Discuss polymorphism in c++. Explaining Polymorphism 2. Write a program in c++ to read a 3X2 matrix and find smallest number in that matrix. Writin

Spider webs have two types of silk, sticky silk and strength silk, spiders do not move on the sticky silken threads only on the strength threads. Assume one type of spider creates

i need a program for finding the last fibonacci number


A: In C++ a struct is alike to a class except for the default access specifier( refer to other question in the document). In C we ought to include the struct keyword while declarin

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers. Descriptions of this algorithm are available in algebra books


Binomial coefficients are the numeric factors of the products in a power of a binomial such as (x + y)n. For example, (x + y)2 = x2 + 2 x y + y2 has the coefficients 1 2 1. Binomia