简体   繁体   中英

Where does the local static variable inside static member function resides in memory?

Where does the local static variable inside static member function resides in memory? For example:

class Foo
{
public:
    static void Bar()
    {
         static int fooBar;
    }
};

Where does 'fooBar' resides in memory and when it was allocated.

That is obviously compiler and platform specific but generally, on PC, it resides in same memory as global variables. It gets initialized on first entry to the function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM