Вы можете сделать это, сделав переменную static:
static
int* count() { static int myInt = 5; return &myInt; }