public inbox for
 help / color / mirror / Atom feed
From: Todd Hoff <>
Cc: C++ Embedded <>
Subject: Re: static function tables
Date: Sat, 27 Jun 1998 08:40:00 -0000	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

Ken wrote:
> What's the right way to do static tables containing function pointers in
> C++?
> I have an embedded C app that parses a command from a host and looks it
> up in a group of tables. Each table represents an array of related
> commands. It contains an 8-byte char[] of the command, a parameter
> count, some flags, and a pointer to the function that handles that
> command. There are several such tables, linked in based on what feature
> set a given app will have.
> When I move this app to C++, what's a reasonable OOP-ish way of handling
> these tables?

How about not using function pointers? Maybe use a table of command
objects instead? You could have a base command class then
derive more specific commands from these. The table would
contain pointers to command objects so you could treat all
the command the same but the behaviour would be that of the
derived class. Not sure if this fits your app but if it works
it is better than using function pointers. Function pointers
should be very rare in a c++ app.

   Desperate measures require the invention of desperate times. 
      -- Todd Hoff

  reply	other threads:[~1998-06-27  8:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-06-27  1:34 Ken
1998-06-27  8:40 ` Todd Hoff [this message]
1998-06-29 17:27   ` Ken
1998-06-29 19:55     ` Todd Hoff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).