General discussion

Locked

Keeping functors and functions together

By debate ·
Tell us what you think about keeping functors and functions together in an array, as featured in our Aug. 7, 2002 C++ newsletter. How have functors and functions been useful to you?

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

This tip isn't finished...

by kevlin In reply to Keeping functors and func ...

Alas, the technique described in this C++ tip demonstrates one way of not solving this problem :-( It is at best half the solution, but it fails to finish the job, leaving memory management unencapsulated, exposing the user to far, far more complexity than they need.

The final solution can -- and should -- be simpler in implementation and easier to use. For the relevant techniques, have a look at my CUJ online article from November 2000, "Function Follows Form":
http://www.cuj.com/experts/1811/henney.htm

Kevlin

Collapse -

You are partially correct

by John Torjo In reply to This tip isn't finished.. ...

Hi Kevlin,

Thanks for your feedback.
You are partially correct. It was sloppy of me to leave out memory management.

However, should have I included that, I guess the code would have become more complicated.

In a future tip, I will show a way to be able to keep pointers in a container, and manage memory management (destruction) internally.

John

Back to Web Development Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums