Why can't we declare a static variable within a structure in the C programming language?
views:
99answers:
2
+4
A:
Because C is not C++.
Because the C standard does not permit it.
Because it has no meaningful interpretation in C.
Jonathan Leffler
2010-09-19 07:37:50
(zing)
Delan Azabani
2010-09-19 07:39:01
+4
A:
In C++, a struct is basically a class with all members public, so a static variable makes good sense there.
In C, a struct is a contiguous chunk of memory with fields. A static variable can not be created without changing that (as to implement a static you need to refer to a single memory location from all structs of that type), and that would be a big difference in complexity without much benefit.
MaxVT
2010-09-19 07:42:24