flexible function parameter
From: Michael (mic457_at_gmx.net)
Date: 04/30/04
- Next message: Allan Bruce: "Re: flexible function parameter"
- Previous message: Alan J. McFarlane: "Re: NO_EXT_KEYS and strict ISO/ANSI modes"
- Next in thread: Allan Bruce: "Re: flexible function parameter"
- Reply: Allan Bruce: "Re: flexible function parameter"
- Reply: Al Bowers: "Re: flexible function parameter"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 30 Apr 2004 15:19:25 +0200
Hi all,
I've got a question according the design
of a parameterlist in C. I am going to have
a function taking two parameters.
One is supposed to be used as a flag, which
determines the type of data is needed, which
is passed to the function by the second parameter.
The type of this parameters differs depending on
the flag. E.g.
void doSomething ( int flag, <seeBelow> value)
{
...
switch flag
{
case 1: // I need value to be a double
...
case 2: // Value shoud be an int
...
}
...
}
Since the number of different types is finite,
I wonder what is the best bet to pass the 2nd Parameter
a) Build a struct, containing all possibilities
of which only the needed are set
b) Use a void pointer
c) Something else
Thanks
Michael
- Next message: Allan Bruce: "Re: flexible function parameter"
- Previous message: Alan J. McFarlane: "Re: NO_EXT_KEYS and strict ISO/ANSI modes"
- Next in thread: Allan Bruce: "Re: flexible function parameter"
- Reply: Allan Bruce: "Re: flexible function parameter"
- Reply: Al Bowers: "Re: flexible function parameter"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|