is temporarily transferred to the invoked function Next statement executed is

Is temporarily transferred to the invoked function

This preview shows page 15 - 23 out of 27 pages.

is temporarily transferred to the invoked function Next statement executed is the first one in the invoked function cout << " Enter number: " ; double a; cin >> a; y = f(a); cout << y; double f(double x) { double result = x*x + 2*x + 5; return result; }
Image of page 15
Invocation Process Flow of control is temporarily transferred to the invoked function After function completes its action, flow of control is returned to the invoking function and the return value is used as value of invocation cout << " Enter number: " ; double a; cin >> a; y = f(a); cout << y; double f(double x) { double result = x*x + 2*x + 5; return result ; }
Image of page 16
Execution Process Function body of invoked function is executed Flow of control then returns to the invocation statement The return value of the invoked function is used as the value of the invocation expression
Image of page 17
The Preprocessor All preprocessor directives are begin with # and it must be the first nonwhitespace character on the line. File inclusion directives #include <filename> #include ”filename” Conditional compilation #define //define a micro #undef //make a micro undefined #if #else #ifdef //if a micro is defined #ifndef //if a micro is undefined #endif //end of a conditional compilation block
Image of page 18
The Preprocessor Examples: #ifndef _HEADER_ABC #define _HEADER_ABC //contents of header file #endif // _HEADER_ABC In C/C++ header file we commonly use the conditional compilation like this to avoid the repeated inclusion of header file. #define _WIN32_MFC #ifdef _WIN32_MFC CString strName = ”ABC”; #else string strName = ”ABC”; #endif
Image of page 19
Libraries Libraries Library Collection of functions, classes, and objects grouped by commonality of purpose Include statement provides access to the names and descriptions of the library components Linker connects program to actual library definitions Previous examples String: STL’s string class Graphics: EzWindows
Image of page 20
Basic Translation Process Process preprocessor directives to produce a translation unit Executable Unit Source program Check translation unit for legal syntax and compile it into an object file Link object file with standard object files and other object files to produce an executable unit
Image of page 21
Some Standard Libraries fstream File stream processing (page 258) assert C-based library for assertion processing (page 268) iomanip Formatted input/output (I/O) requests (page 251) ctype C-based library for character manipulations math C-based library for trigonometric and logarithmic functions Note C++ has many other libraries
Image of page 22
Image of page 23

You've reached the end of your free preview.

Want to read all 27 pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes