jweinst1
11/13/2017 - 8:42 PM

How to provide global access to locally scoped static variable.

How to provide global access to locally scoped static variable.

Global Static Variables

Here is example of how to provide global access to local static variable.

Foo.h


#ifndef FOO_H
#define FOO_H

void setGlobal(int value);

int getGlobal();

#endif

Foo.cpp

static int globalInt = 0;

void setGlobal(int value)
{
  globalInt = value;
}

int getGlobal()
{
  return globalInt;
}