lack of C's static local variables

C

Chris Uppal

Digital said:
I nominate this reply for Most Worthless Posting of the Year.

I nominate this reply for Most Unpopular Posting of the Year.

;-)

-- chris
 
T

TGOS

I was just wondering - coming from a mostly C background, Java lacks C's
static variables

They are not needed.
Static
class members aside, what other techniques do people use when they want the
same kind of functionality?

You wouldn't use static variables, just private ones.

The idea of the C static variables is that calling a function leaves it
in a certain kind of "state" and when you call it again, the "state" is
preserved. Therefor every information that makes up the state has to be
saved in a static variable.

Java is OO, that means you must learn to think in type of objects. Every
object itself has an internal state, which is held by all kind of
private variables of that object and the state is influenced by calling
methods of the object.

Using static variables in C, it would be a state for the class, but that
makes little sense, as you may want to have three objects of that class,
each in a different state.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,061
Latest member
KetonaraKeto

Latest Threads

Top