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
  • 391
  • 1
  • 8
  • 27

1 Answers1

3

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

Luchian Grigore
  • 245,575
  • 61
  • 446
  • 609