"nick" <i1********@yahoo.com> wrote in message
news:dl***********@justice.itsc.cuhk.edu.hk...
: 1.int const x=5;
: const int x=5;
:
: 2.const char *p=new char[20];
: char const *p=new char[20];
:
: the above pairs are equivalent?
Yes, so which one you use is a matter of stylistic convention.
I only use a leading const for true compile-time constants:
const int x = 5;
const double pi = 3.1415926535;
(note that these are never composite types).
In all other cases, I put const *after* the type it affects:
char const *const p = new char[20];
int const h = getHeight( myWindow );
hth -Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Brainbench MVP for C++ <>
http://www.brainbench.com