I do not understand the difference between these two statements in my C++ class:
class MyClass {
public:
private:
static const int var = 0; // Option 1
const static int var = 0; // Option 2
};
What is the difference b/w Option 1 and Option 2?? They both compile.
They mean exactly the same thing. You’re free to choose whichever you think is easier to read.
In C, you should place
staticat the start, but it’s not yet required. I’m not sure if C++ followed C in this regard.