Discussion Locked

Keeping functors and functions together

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
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?

2 replies

by kevlin

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

by john torjo

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

This discussion is closed to new replies.