| | | Dave Harris |  |
| Posted: Tue Aug 26, 2008 3:51 pm Post subject: Re: Which design in better? (Also posted in comp.lang.c++) |  |
| |  | |
niteshchordiya@gmail.com (Nitesh) wrote (abridged):
| Quote: | Objects of type X are basic building blocks of my application and there are a few functions which return XHandle (typedef X** XHandle). The task at hand needs to use a couple of these functions and then iterate over X objects. Because its done frequently and it separates iteration from task-at- hand'logic we decided to create iterator.
|
I don't see why you can't have a single iterator class with a suitable constructor:
XHandleIterator::XHandleIterator( XHandle handle, int count );
and then various functions that return such iterators:
XHandleIterator makeIterator( SomeType obj );
Your first design introduces this function via a derived class, and your second design makes it a policy, but why can't it just be a plain simple function?
-- Dave Harris, Nottingham, UK.
-- [ See LINK for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |
|