Did you try it?eboyd wrote:will this work:Code: Select all
T& operator*() { return(aNode->getVal()); }
iters
Is it OK to have a get_T() function? If so, should it be:
Mmmmmm.....
who calls this function anyway? Node or List?
me = confused.
Code: Select all
const T get_T(){ return T; }
who calls this function anyway? Node or List?
me = confused.
You really should go take a look at the list specification of the STL which explains a bit about what's where. Consider these parts of logic:eboyd wrote:Is it OK to have a get_T() function? If so, should it be:
Mmmmmm.....Code: Select all
const T get_T(){ return T; }
who calls this function anyway? Node or List?
me = confused.
A list object contains a number of nodes and can provide you with iterators on the list. It can also provide you with metrics on the list as well as operations on the list.
Each node object contains a pointer to a single object (or none, in which case it would be a sentinel).
Each iterator acts as a pointer to a node, with operator++ to go to the next node, operator-- to go to the previous node and operator* to give the object to which the node points.
Spec from the SGI site:
http://www.sgi.com/tech/stl/List.html
Making an implementation of a generic component is a prime candidate for a test framework. You could try to use the framework I've created yesterday evening (bit of a promo) for testing it. If you use it as a TDD setup, you can create your list to match what you want from it.
The idea is, set up a test case, add a call to a function you would like to do something. The compile fails, since it isn't there. Add a plain stub with the right signature.
It compiles, but the test fails (if it doesn't make a more useful test ). Fix the function and the class to make this test compile and to make all previous tests still work. Repeat as desired.
http://www.atlantisos.org/index.php?pageId=68 contains the documentation and an example, the source is in http://atlantisos.svn.sourceforge.net/v ... s/test/fw/ . You need the two headers and both the source files, the makefile is optional. Compile suite.cc into an object, create a file (or multiple) with test cases and link that to an executable (no main function necessary - it's taken care of). Run the executable and watch the tests for the results.
Last edited by Candy on Sat Oct 06, 2007 1:37 am, edited 1 time in total.
Hey thanx! I'll try the TDD framework probably tomorrow (I have my daughter the rest of this evening).
Yea, I guess I'm not so confused w/the underlying logic of this whole *iter* situation, it's more of the overall point/setup I'm missing (if that makes any sense).
Haha, (re-reading through your post) I guess my next real homework assignment will be making a makefile that includes your framework and my template class!
Yea, I guess I'm not so confused w/the underlying logic of this whole *iter* situation, it's more of the overall point/setup I'm missing (if that makes any sense).
Haha, (re-reading through your post) I guess my next real homework assignment will be making a makefile that includes your framework and my template class!