Dereferencing array of pointers to functions

Could someone please clarify the last statement in this code?
I don't understand the reason for subtracting 'a' from c
except that the code will compile but will not run.

Thanks,
b52

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Using an array of pointers to functions
#include <iostream>
using namespace std;

// A macro to define dummy functions:
#define DF(N) void N() { \
   cout << "function " #N " called..." << endl; }

DF(a); DF(b); DF(c); DF(d); DF(e); DF(f); DF(g);

void (*func_table[])() = { a, b, c, d, e, f, g };

int main() {
  while(1) {
    cout << "press a key from 'a' to 'g' "
      "or q to quit" << endl;
    char c, cr;
    cin.get(c); cin.get(cr); // second one for CR
    if ( c == 'q' )
      break; // ... out of while(1)
    if ( c < 'a' || c > 'g' )
      continue;
    (*func_table[c - 'a'])();
  }
}
'a' - 'a' is 0
'b' - 'a' is 1
'c' - 'a' is 2

Need I say more?
Does anyone have a spare Southwest Airlines ticket?

Thanks Athar.

b52
Topic archived. No new replies allowed.