|
||
Title: No static variables in union? Post by hoogle on Sep 25th, 2008, 9:01pm Why cant we declare static variables in union? |
||
Title: Re: No static variables in union? Post by GowriKumar on Sep 25th, 2008, 11:11pm I'm little confused about the question. Is the question why this is not allowed: union foo{ static int il; }; If yes, the following explanation might help: static keyword applies for variables/functions, but not the names inside the structures/unions. union foo { int i; int j; }; static union foo f; /* f is of type union foo and is static */ Regards, Gowri Kumar |
||
Title: Re: No static variables in union? Post by towr on Sep 26th, 2008, 2:20am A union allows you to address the same element of data in different ways. Now this would clearly pose a problem if it is at the same time static and not static. |
||
Title: Re: No static variables in union? Post by RajivG on Sep 27th, 2008, 1:17am now after reading it i got a problem ::) normally we do not implement grammar where i feel infeasibility of semantic and syntax implementation. static variable in structure--------- > i do not see any problem, this is what c++ compiler does when we ask it to give a class with static member.. as essentially class nothing but a structure now if it is question of Union and i make rule that all members should be static then complier should allow this can some one put some light ? what problem can be there either semantic of syntactic |
||
Powered by YaBB 1 Gold - SP 1.4! Forum software copyright © 2000-2004 Yet another Bulletin Board |