Re: How to convert string to operator
  Home FAQ Contact Sign in
comp.lang.c++ only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.c++ Profile…
 Up
Re: How to convert string to operator         


Author: Dizzy
Date: Jun 12, 2007 03:33

V.R. Marinov wrote:
> On Jun 12, 7:56 am, shsingh gmail.com> wrote:
>> I have a function which takes two operands (char*) and a operator
>> (char*)
>>
>> int myFunc(char* operand1, char* operand2, char* myoperator);
>>
>> Depending upon the operator, i want to do the manipulation on both
>> operands. I dont want to hardcode the operator values or use of switch/
>> if-else statement to determine the operation.
>> Is there any way to solve this problem ??
>
>
> In C++ there are at least two ways to get rid of a switch:
> - Factory design pattern
> - Array of pointers to functions
Show full article (1.84Kb)
no comments