C++ question for hugin
Pablo d'Angelo
pablo at mathematik.uni-ulm.de
Tue Jul 22 15:41:12 BST 2003
Hallo Kai-Uwe!
Kai-Uwe Behrmann schrieb am Dienstag, den 22. Juli 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;
> }
Ok, what you called "type" is the name of a member of the foo and bar
structs,
right?
if foo and bar only contains a members of a single type, then you can
use a
associative array for that. (std::map and std:multimap are
implementations of associative array's in the c++ standart library.)
Where do you need that functionality?
> thanks, as well for explaining it is outside C++ or another language
> can do
Thats not possible with C or C++, they are to static for this.
Hmm, I think there is a way to archive part of what you want with
templates. But maybe its easier to find another solution.
ciao
Pablo
--
http://wurm.wohnheim.uni-ulm.de/~redman/
Please use PGP
More information about the ptX
mailing list