Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   typedef error (http://www.go4expert.com/forums/typedef-error-t8743/)

phiber_optik 10Feb2008 14:35

typedef error
 
typedef int T;
main()
{
T T=5; //no error
}

but in the following case, I get an error
main()
{
typedef int T;
T T=5; /error
}

Lucius 10Feb2008 23:31

Re: typedef error
 
Code:

typedef int T; // define global symbol 'T'
int main()
{
  T            // use global symbol 'T'
    T          // declare local symbol 'T' that
              // from this point on "shadows" the
              // global 'T' which main can no
              // longer access.
              // E.g.,  T S = 7; is an error
      = 5;    // ...
}

Code:

int main()
{
  typedef int T; // define local symbol 'T'
  T T = 5;      // re-define local symbol 'T' (error)
}



All times are GMT +5.5. The time now is 05:42.