SRR wrote On 02/26/07 10:00,:
Can anyone tell me if it is really possible to do declare 100
variables without "explicitly typing it"?
Consider the following:
int var1=0;
int var2=0;
..........
...........
int var99=0;
int var100=0;
The job is to write a "short" macro which when used, pastes the above
declarations in the code.
It's certainly possible, given a suitably lenient
definition of "short."
Under any definition, though, it's a stupid thing
to do. Given those declarations, how will you use the
hundred declared variables? Answer: For each operation
you want to perform you will need to write a hundred
versions of the statement that performs it, plus some
more code to choose which of the hundred statements you
want to execute. You will type your little fingers to
the bone. You will make at least two typographical
errors, at least one of which will escape the notice of
the compiler, e.g.
switch (which) {
case 1: var1 = x; break;
case 2: var2 = x; break;
...
case 85: var85 = x; break;
case 86: var85 = x; break;
...
case 99: var99 = x; break;
case100: var100 = x; break;
}
.... and you will have made far more trouble for yourself
than I would wish on anyone.
--
Er*********@sun.com