1 / 4

C++ Models

C++ Models. Jim Fawcett CSE687 – Object Oriented Design Spring 2007. C/C++ Compilation Model. C/C++ Computational Model. public global functions and data. private global functions and data. local static data. allocated heap memory. free heap memory. free memory. C/C++ Memory Model.

ronh
Télécharger la présentation

C++ Models

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. C++ Models Jim Fawcett CSE687 – Object Oriented Design Spring 2007

  2. C/C++ Compilation Model

  3. C/C++ Computational Model

  4. public global functions and data private global functions and data local static data allocated heap memory free heap memory free memory C/C++ Memory Model Static memory: - available for the lifetime of the program defined outside any function (globals) and initial- ized before main is entered. global data and functions are made private by qualifying as static, otherwise they are public memory allocations local to a function, but quali- fied as static Stack memory: - temporary scratch pad - defined only while computational thread passes through a function. - holds input parameters, local data, and return values, used as scratch-pad memory - guaranteed to be valid during the evaluation of a containing expression, won’t be valid after - expression evaluation starts with function eval- uation first, then expression evaluation as alge- braic combination of terms - stack frame is destroyed when expression eval- uation is complete main stack frame function called by main stack frame more stack frames : current function stack frame heap memory: - valid from the time of allocation to deallocation - allocated/deallocated at run time by invoking operators new /delete (or functions malloc/free) - memory is available to anyone with a pointer to the allocated memory from the time of allocation until deallocated.

More Related