1.
I have a virtual method reset() and I have a non-virtual member function
propagate_reset whose definition is as follows:
void GroupedComponent::propagate_reset(void)
{
reset();
list<GroupedComponent *>::iterator first = children.begin();
list<GroupedComponent *>::iterator last = children.end();
while (first != last)
{
(*first)->propagate_reset();
first++;
}
}
Now, I want to turn it into a function that accepts a callback so I can
later pass other signals there. Assume that all signals have the same
declaration. How can I write a tree iterator like this?
Will the following defintion:
void GroupedComponent::propagate_signal(void
(*GroupedComponent::callback)(void))
{
callback();
list<GroupedComponent *>::iterator first = children.begin();
list<GroupedComponent *>::iterator last = children.end();
while (first != last)
{
(*first)->propagate_reset();
first++;
}
}
propagate callback correctly across types?
2. I want to destroy a dynamically allocated object without knowing its
exact class in advance. I can declare a virtual destroy method that will
call (delete this;), but I'll have to do it for each inheritance level. Is
there a better way.
Regards,
Shlomi Fish
----------------------------------------------------------------------
Shlomi Fish [EMAIL PROTECTED]
Home Page: http://t2.technion.ac.il/~shlomif/
Home E-mail: [EMAIL PROTECTED]
"Let's suppose you have a table with 2^n cups..."
"Wait a second - is n a natural number?"
=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]