Chapter Contents |
Previous |
Next |
SAS/C C++ Development System User's Guide, Release 6.50 |
Compilers
for ANSI C and older C++ compilers allow implicit pointer qualification conversions
such as
int**
to
const int**
that are not type-safe.
For example:
void set_it( const int** target, const int* source ) { *target = source; } void test_it( const int* const_ptr ) { int* nonconst_ptr; // Get a non-const copy of const_ptr // without casts!! // The first argument uses the old unsafe // implicit conversion. set_it( &nonconst_ptr, const_ptr ); *nonconst_ptr = 0; // assignment through // const pointer } |
To avoid a similar problem with the C++ type system, the draft version of C++ allows only a subset of the implicit qualification conversions allowed in ANSI C. This subset can be summarized as follows:
const
. For example, an
int**
pointer cannot be implicitly converted
to
const int**
but it can
be implicitly converted to
const int* const * |
For more information on implicit pointer qualification conversions, refer to section 4.4 of the ISO C++ draft.
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.