delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/17/23:45:33

Message-ID: <37914CDD.54F4ABC1@vetec.com>
Date: Sat, 17 Jul 1999 22:41:17 -0500
From: Andy Goth <andygoth AT vetec DOT com>
X-Mailer: Mozilla 4.61 [en] (Win95; I)
X-Accept-Language: en
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: Need help with class stuff
References: <TnNj3.667$3C2 DOT 65692 AT wagner DOT videotron DOT net> <3790A2D4 DOT 204E0595 AT homemail DOT com>
Reply-To: djgpp AT delorie DOT com

> > char Test::select(char key)
> > {
> >   switch(key)
> >   {                                             // I get the warning at
> >    case '1': Action = &Print1; break; // this line
> >    case '2': Action = &Print2; break;      // And this line
> shouldn't this          ^^^^^^^ be
>      case '1': Action = Print1; break;
>      case '2': Action = Print2; break;

Yup.  The name of a function serves as a pointer to the code.

Another common mistake is to do:

case '1': Action = Print1(); break;

What this means is "Set Action to equal the return value of Print1()." 
This is not what you want here.

> >     default : return 1;
> >   }
> >   return 0;
> > }
  ___  _   _ ____  _   _
 / _ \| \ | |  _ \\ \_/ / .--------[ ICQ#: 35256413 ]--------.
| |_| |  \| | | | |\   /  | 01001000011001010110110001101100 |
|  _  | \ \ | | | | | |   | 01101111001011000010000001110111 |
| | | | |\  | |_| | | |   | 01101111011100100110110001100100 |
|_| |_|_| \_|____/  |_|   `--[ mailto:andygoth AT vetec DOT com ]---'
<http://zap.to/andygoth/>           <http://andygoth.cjb.net/>

- Raw text -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019