What reasons are there to place member functions before member variables or vice/versa?
- by Cory Klein
Given a class, what reasoning is there for either of the two following code styles?
Style A:
class Foo {
private:
doWork();
int bar;
}
Style B:
class Foo {
private:
int bar;
doWork();
}
For me, they are a tie. I like Style A because the member variables feel more fine-grained, and thus would appear past the more general member functions. However, I also like Style B, because the member variables seem to determine, in a OOP-style way, what the class is representing.
Are there other things worth considering when choosing between these two styles?