The question is, what would be the best or maybe a better practice to use. Suppose I have a function, which belongs to some class and this function needs to use some static variable. There are two possible approaches - to declare this variable as class's member:

```
class SomeClass
{
public:
    ....
    void someMethod();
private:
    static int m_someVar;
};

SomeClass::someMethod()
{
    // Do some things here
    ....
    ++m_someVar;
}

```

Or to declare it inside the function.

```
class SomeClass
{
public:
    ....
    void someMethod();
};

SomeClass::someMethod()
{
    static int var = 0;
    ++m_someVar;
    // Do some things here
    ....
}

```

I can see some advantages for the second variant. It provides a better encapsulation and better isolates details of an implementation. So it would be easier to use this function in some other class probably. And if this variable should be modified only by a single function, then it can prevent some erroneous data corruption from other methods.

While it's quite obvious, that the first variant is the only one to use when you need to share a static variable among several methods (class functions), the question pertains the case when a static variable should be used only for a single function. Are there any advantages for the first variant in that case? I can think only about some multi threading related stuff...