1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

Linkage of const variables

Unlike C, const variables declared at the outermost level have internal linkage by default:

#include <iostream.h>

const int zero = 0;// Internal in C++, External in C extern const int one = 1;// External in both C++ and C static const int two = 2;// Internal in both C++ and C

References to pointers

References to pointers can be used in place of "pointers to pointers'':

#include <iostream.h>

void setstr( char* &var, char* str )
{ var = str; }

int main() {
char* s;
setstr(
s, "hello" );
cout << "s is '" << s << "'" << endl;
}
The output is:

s is 'hello'

22-Mar-98

Page 13

C201/TAM