![]() Chapter Contents |
![]() Previous |
![]() Next |
SAS/C C++ Development System User's Guide, Release 6.50 |
Most C++ programs need to access some of the classes and functions contained in the libraries provided with the SAS/C C++ Development System. These classes and functions are declared in header files. In addition, you can have header files of your own. Using the SAS/C C++ Development System under TSO, CMS, MVS Batch, and OpenEdition , describes how header files are stored and named under your operating system. Here are some other tips to keep in mind when you use header files in C++ programs:
< header-filename.h>
Use this form for your own header files:
"header-filename.h"
The following header files are supplied with the standard libraries:
complex.h |
iostream.h |
strstream.h |
bsamstr.h |
new.h |
typeinfo.h |
fstream.h |
stream.h |
|
iomanip.h |
stdiostream.h |
Except for
new.h
,
stream.h
, and
typeinfo.h
, the contents of these header files
are described in I/O Class Descriptions
. The contents of
stream.h
are described in stream.h header file
.
The contents of
new.h
are as follows:
void* operator new(size_t size)
operator new
tries again to allocate memory, and if that fails, it again calls the new-handler.
This process repeats until either
operator new
can allocate some dynamic
memory or the new-handler is removed.void * operator new(size_t size,
void* location);
size
argument and simply returns the
location
argument as its result.
This version of
operator new
is used to construct objects at a
specified location. void operator delete(void* ptr)
ptr
.void (*set_new_handler (void(*handler)()))()
operator new
. The new-handler is
called if
operator new
cannot allocate any dynamic memory. The new-handler
function takes no arguments and returns
void
. The new-handler should free
some memory before returning to its caller, or an endless loop could result.
If it cannot free any memory, it should terminate the program via
exit
or
abort
. Another alternative is to remove itself as a new-handler by
calling
set_new_handler
with NULL or a pointer to some other handler.
set_new_handler
returns the previous new-handler or NULL if there was not a previous
new-handler. The class,
functions, and types
declared in the
typeinfo.h
header file are provided to identify and compare types, and to control run
time error handling for Run Time Type Identification, or RTTI. The class
type_info
is declared
in this header file. A description of the functions, operators,
and types found in
class type_info
is included in this section. Release 6.50 of the SAS/C C++ Development
System does not support exceptions so a mechanism corresponding to default
handling of an exception is invoked for these errors. Descriptions of the
run time error handling type
terminate_handler
and functions
set_terminate,
and
terminate
are also included in this section.
See Appendix 4 for more information on RTTI.
#include <typeinfo.h> class type_info { public: virtual ~type_info(); int operator==(const type_info& rhs) const; int operator!=(const type_info& rhs) const; int before(const type_info& rhs) const; const char* name() const; };
<typeinfo.h>
. The RTTI operator
typeid()
returns a reference to a
const
object of this type. Such objects are created by the C++ implementation
to provide an identifier for types. The class allows two
type_info
objects to be compared for type equivalence,
or compared for order in an arbitrary collating sequence of types. It also
allows a printable description of the represented type to be retrieved.
int operator==(const type_info&
rhs) const;
type_info
objects represent the same type, and returns 0 otherwise.int operator!=(const type_info&
rhs) const;
type_info
objects represent the same type, and returns 1 otherwise.int before(const type_info&
rhs) const;
rhs
in an arbitrary collating sequence of types, and returns 0 otherwise. This
order is arbitrary and may change in different program loads.const char* name() const;
type_info
object. The function calls operator
new
to allocate working
storage. The result is cached so it should not be deallocated by the user.#include <typeinfo.h> typedef void (*terminate_handler)(); terminate_handler set_terminate (terminate_handler new_handler); void terminate();
terminate_handler
terminate()
is called. The handler function must end the program without returning. old_handler = set_terminate(new_handler);
terminate();
terminate()
. The default handler calls
abort()
.
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © Tue Feb 10 12:11:23 EST 1998 by SAS Institute Inc., Cary, NC, USA. All rights reserved.