On Jun 11, 12:28 am, Old Wolf <oldw...@inspire.net.nzwrote:
On Jun 11, 12:25 am, Szabolcs <szhor...@gmail.comwrote:
The syntax for typedef is the same as the syntax for declaring
variables, but the name of the new type (new-type in your example)
is substituted for the variable name.
And the keyword 'typedef' is added as a qualifier would be.
As a storage class would be. Although order is irrelevant
according to the standard, and things like:
int typedef *ptr ;
and
const int* ptr ;
are technically legal, good programming practice always puts the
typedef first, and the best current practice tends to put the
const after the int, i.e.:
typedef int* ptr ;
and
int const* ptr ;
For historical reasons, actual practice concerning the placement
of constvaries a lot. On the other hand, the C standard says
"The placement of a storage-class specifier other than at the
beginning of the declaration specifiers in a declaration is an
obsolescent feature", and C considers typedef a storage-class
specifier. (I have no idea whether there is any intention to
ever adopt this rule in C++. But for as long as I can remember,
by convention, the various non-type specifiers (register,
static, extern, mutable, auto, inline, virtual, explicit,
typedef, and friend) have always come before any type specifier.
It's a convention that shouldn't be ignored.
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34