[LC++]typedefs in C++
Palaka, Sasidhar
psasi at corp.untd.com
Fri Sep 13 02:26:07 UTC 2002
Oh! I have been stupid for forgetting this simple rule.
Thanks Bill,
Sasi.
-----Original Message-----
From: Bill Rausch [mailto:William.Rausch at numerical.com]
Sent: Thursday, September 12, 2002 9:51 PM
To: tuxcpprogramming at lists.linux.org.au
Cc: Palaka, Sasidhar
Subject: Re: [LC++]typedefs in C++
At 9:24 PM +0530 9/12/02, Palaka, Sasidhar wrote:
>2) #include<stdio.h>
> typedef int nums[4];
> main()
> {
> nums np;
> np[2] = 3;
>
> int nq[4];
> nq[2] = 3;
> printf("My value = %d %d", np[2], nq[2]);
> }
>
>Output I got: Compilation errors with gcc,
> Compiles and runs with g++.
>
>
>Now, my question is why is not running with gcc in the
>second case? I guess, I am missing some funda with
>respect to the differences between C and C++ as far as
>'typedef's are concerned. Can somebody point out, what
>am I missing here?
Move the "int nq[4];" line to the top of the block. In ordinary C,
all declarations have to come at the beginning of the block.
Bill
--
Bill Rausch, Software Development, UNIX, Mac, Windows
Numerical Applications, Richland, WA 509-943-0861 x302
More information about the tuxCPProgramming
mailing list