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
PROGRAM TO FIND WHETHER A NUMBER IS ODD OR EVEN int main() { int number ; printf("Enter a whole number\n"); scanf("%d",&number); if(number % 2 == 0) printf("n

#include #include using namespace std; class Book { private: string title; int iD; int year_pub; string author; public: string getTitle(); int getId(); int getYear_Pub(); st

Templates permit to create generic functions that admit any data type as parameters and return value without having to overload the function with all the possible data types. Until

how i can open a file

write a C rpogram that can display the transpose form of a ciphertext matrix.Prompt users to provide row and coloumn number of matrix.Then user will input plaintext and the program

A: This is a name that acts as an alias, or alternative name, for a beforehand defined variable or an object. prepending variable along with "&" symbol makes it as reference. fo

need an expert programmer to finish coding the requirements from the assignment withen 4 hrs

Can I explicitly call a destructor if I've allocated my object with new?

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

write a javaprogram to solve padovan string using java? program in java // aakash , suraj , prem sasi kumar kamaraj college program 1 : package test.padovanstring;