Quote:Which one is better?
Using global variables tends to make for lousy object-oriented designs. You should design your systems without thinking about either global variables or global state.
Quote:if i declare a member of a class i always put m_ in front of it to indicate its a member of the class.
Initializer lists? Bar() : foo(10) {} : it's obvious that it's a member, no need to say it twice.
Member access? bar.foo : it's also obvious that it's a member, no reason to repeat it.
Member pointers? &Bar::foo : still obvious and not worth repeating.
Small functions? int Bar::Foo() const { return foo; } : either a member or a global but, since there are no globals in your code, you just know it's a member, so still not worth repeating.
Ambiguites? this -> foo : yes, this does take four more characters to write than the m_ prefix, but it's rare enough that it is largely offset by the lack of prefix in all other cases.
Quote:Also for an int i always put i in front of it to show its an int.
It's far better to use semantical denotation which implies that it's an integer (such as countFoo or numFoo or indexFoo or remainingFoo) or simply drop the type information because it's not relevant (fooHandle).