2

For below singleton class where would be the memory taken from (Stack or Global memroy)

class Singleton
{
    public:

        static Singleton* get()
        {
            static Singleton instance;
            return &instance;
        }
};
Ashwin
  • 411
  • 1
  • 10
  • 28

1 Answers1

3

instance will be located in static storage (or global as you call it).

Luchian Grigore
  • 253,575
  • 64
  • 457
  • 625