Spyke
jdr
lemmy.ml

Young man, could.you explain your shitpost?

3
fiahreply
discuss.tchncs.de

int variable => local scope => my int from the perspective of an instance

static int variable => class scope => our int, for all instances of a class

10

personally I prefer including the file

prog_constants.h

int program_state; // Keeps track of stuff

in all translation units. That way I can easily keep track of what different parts of the program are doing at any time by modifying a single variable.

3

That's a nice idea. You can always put a pointer there if you need more state.

It just doesn't work on machines with different int and pointer sizes. On the benefit of interoperability, I suggest you make it a (void*). So one function can set it program_state = (void*)'K'; while some other one can set it program_state ={1, 32, 768}; and yet another can do program_state = "I'm in the middle of something here!";.

2
lemmy.ml

This is a great one. I'm definitely using it in class this fall to explain static variables.

1

You reached the end