I have a pre-existing source code in C similar to below.
bool getFlag(int param)
{
static bool flag = false;
if(param == 1)
flag = true;
return flag;
}
I have written the C++ version of the same as below.
class MyClass
{
public:
static bool getFlag(int param)
{
if(param == 1)
flag = true;
return flag;
}
private:
static bool flag;
};
What is the difference between the above two code snippets? Does the C++ code above has advantage over the C code in any ways?