Mail Archives: djgpp/1996/11/08/09:36:16
BDC Client Team (cs19 AT cityscape DOT co DOT uk) wrote:
: int p=0,d[4]
: It is obviously defining an integer variable 'p' and assigning a start value
: to it - can anyone help me with the right-hand side of the '=' sign ?
: There is no reference to a variable 'd' in the rest of the code, so I assume
: that, in this case, 'd'is recognized by the compiler as a function/constant
: of some kind.
You'll kick yourself...
In C, if you write:
int p,d;
it declares 'p' and 'd' to be of type 'int'. If you write:
int p,d[4];
it declares 'p' to be an 'int' and 'd' to be a pointer to 5 'int's.
In C++, writing:
int p=0,d[4];
declares 'p' as and 'int' and sets it to zero, and also declares 'd' to
be a pointer to 5 'int's. It's the same as:
int p=0;
int d[4];
The '=' sign has a higher precedence than the ','.
--
George Foot
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ |""""""""""""""""""""""|
>Email: george DOT foot AT merton DOT ox DOT ac DOT uk < |Snail Mail:(*) |
> or: mert0407 AT sable DOT ox DOT ac DOT uk < | _ George Foot |
> Web: http://users.ox.ac.uk/~mert0407/ < |(@) Merton College |
> Ftp: mc31.merton.ox.ac.uk (#) < |~~~~ Oxford OX1 4JD |
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ |______________________|
(#) Theoretically... || (*) Please allow 28 days for delivery
- Raw text -