Mail Archives: djgpp/1996/11/14/07:58:11
In article <55vc7n$t9e AT news DOT ox DOT ac DOT uk>,
George Foot <mert0407 AT sable DOT ox DOT ac DOT uk> wrote:
>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:
YES it does.
>int p,d[4];
>
>it declares 'p' to be an 'int' and 'd' to be a pointer to 5 'int's.
NO it does not. 4 ints!
>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:
4 ints! And d isn't a pointer, but 'd' specified alone is the location
of the first array item. If it was a pointer, you could reassign it.
>int p=0;
>int d[4];
YES it does.
>
>The '=' sign has a higher precedence than the ','.
Guh? Don't confuse with ',' in a mathematical expression.
--Brennan
--
brennan AT rt66 DOT com | "They are the dead, brought to simulated life by our
Riomhchlaraitheoir| electro-guns."
Rasterfarian | <http://brennan.home.ml.org>
- Raw text -