|
|
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 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'
|
|