FREE Subscription to Dr. Dobb’s Digest: Same Great Content, New Digital Edition
Site Archive (Complete)
C++
Email
Print
Reprint

add to:
Del.icio.us
Digg
Google
Furl
Slashdot
Y! MyWeb
Blink
June 01, 1997

C++

(Page 4 of 9)

June 1997/Being Assertive in C/C++/Listing 3

Listing 3: Checking data structure validity

enum
{
  kEnterOperation,
  kEnterMethod,
  kExitMethod,
  ...
  kDispatchGlue,
  kNUM_ENTRIES
};

class CodeGenerator
{
  ...
  static char* NamesTable[ kNUM_ENTRIES ];
  static void InitNames( void );
};

void CodeGenerator::InitNames( void )
{
  int i;

  for( i = 0; i < kNUM_ENTRIES; ++i )
    NamesTable[ i ] = NULL;

  NamesTable[ kEnterOperation ] = "EnterOperation";
  NamesTable[ kEnterMethod ]    = "EnterMethod";
  NamesTable[ kExitMethod ]     = "ExitMethod";
  ...
  NamesTable[ kDispatchGlue ]   = "DispatchGlue";

  for( i = 0; i < kNUM_ENTRIES; ++i )
    assert( NamesTable[ i] != NULL );
}
//End of File
Previous Page | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next Page
RELATED ARTICLES
No Related Articles
TOP 5 ARTICLES
No Top Articles.



MICROSITES
FEATURED TOPIC

ADDITIONAL TOPICS

INFO-LINK