When we implement static int
member, I usually do like this
class A {
public:
static int a = 5;
};
But once I found the code below, that enables the same thing, I noticed that we can access the member through A::a
. I prefer this because initialization before the main function is not needed as opposed to the static int
class A {
public:
enum { a = 5 };
};
Which one is better?
Is there any benefit of using static int
??