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
hwat is the area fsdjlakl;aeklfjtealrtl;gka

Academic expert for Genetic Algorithm Project Description: Seeking academic expert for Genetic Algorithm. Skills required are Academic Writing, Algorithm, C++ Programming,

Multilevel Inheritance In multilevel inheritance there is a parent class , from whom we derive another class . now from this derived class we can derive another class and so on

Op e r a t o r O v e r l o a d i n g : W h e n   a n   o p e r a t o r   i s   u s e d   f o r   d i ff e r e n t   op e r a

hello i have about 15 hours the dead line I Need a program in c language that''s determine the router ip or the gateway ip of the current NIC example the router ip is: 192.168.1.1

how to create program in c that will system restart

Write a program that finds the minimum total number of shelves, including the initial one required for this loading process.

how do you declare an integer variable

ABC Car Dealership needs your help to update the ordering system. This car dealer is selling four types of vehicles: Sedan, Truck, SUV, and mini Van. And each type of vehicle can h

Program is to check whether the string entered is a palindrome or not: Program is to check whether the string entered is a palindrome or not invoke function from main int p