More flexible parameter passing in C++

Hung Jung Lu hungjunglu at yahoo.com
Mon Dec 31 14:25:43 EST 2001


Hi,

This is a question on C++. I guess I am too spoiled with Python
features. Now it's hard for me to do things in C++. :)

Consider the case of hook methods. You have parent classes that
declare hooks. Well, a parent class may not do much with a hook, but
the child class may do something with it. That's what hooks are for.

Now, the parent class does not know nor does it care what's on the
parameter list. Python can handle all this well: the parameter list
can be quite dynamic in Python. There are many ways to handle dynamic
parameter lists.

But I am having hard time with C++, now.

One way out is to use hashmaps (equivalent to Python dictionaries),
but this is bad for performance.

Is there some object-oriented way of making parameter passing more
flexible in C++? I mean, the goal is avoid modifying the header
declaration of methods... especially in situations where you have
subclasses and sub-subclasses.

I guess this problem is common enough that many people already have
typical solutions (i.e.: patterns). Any thoughts?

regards,

Hung Jung



More information about the Python-list mailing list