A Simple Symbol Table

I'm trying to solve a problem from a book I'm reading which states:
"Write a template class Pair that can hold a pair of values of any type. Use
this to implement a simple symbol table."

What is a symbol table? I also though it was a table that matched it's identifiers with it's attributes but anything I find about symbol tables are about compilation creation and design, but that's usually over my head. I can't get an exact definition or purpose of a symbol table and when I do think I have a good idea what a symbol table is I can't apply it to the question.

Any help is appreciated, thanks.
I assume you've seen


but are still unclear?

In a sentence, it's a table which maps a symbol (e.g. ID, memory address, etc) to a piece of information. (The symbol is whatever is required in the context)

Another good example of a symbol table is the one used by a source-level debugger.


In this case, the table maps program instruction address to variable/function name, type, file, and line number.

As an exercise, you could code something which maps phone area codes to place names. Trivial, but uses the right kind of functionality.

Andy
Last edited on
Topic archived. No new replies allowed.