C++ question for hugin
    Kai-Uwe Behrmann 
    ku.b at gmx.de
       
    Tue Jul 22 15:08:40 BST 2003
    
    
  
Hi,
here are some programmers, so I would like to ask something.
Two classes exist:  class foo with members  int a,b,c    and
                    class bar with members  double a,b,c    .
The function  func()  knows this two objects.
Now I want to do something like (The char is of Your choice.) :
void class_name::func  ( char type )
{
  int    intern_int;
  double intern_float;
  intern_int   = foo.type;
  ...
  intern_float = bar.type;
}
The compiler does not know at runtime wich type and name the variable has.
This is somewhat dynamic. I know only this (complicated) solution:
  if ( type == "a" ) {
    intern_int = foo.a;
    ...
    intern_float = bar.a;
  }
  if ( type == "b" ) {
    intern_int = foo.a;
    ...
    intern_float = bar.a;
  }
thanks, as well for explaining it is outside C++ or another language can do
Kai-Uwe
    
    
More information about the ptX
mailing list