Page 2 of 2

Posted: Fri Oct 05, 2007 11:53 am
by Candy
eboyd wrote:will this work:

Code: Select all

T& operator*()
      {
         return(aNode->getVal());
      }
Did you try it?

Posted: Fri Oct 05, 2007 12:44 pm
by eboyd
Did you try it?
Hahaha! :lol:

I'm sorry. I didn't have a computer w/a compiler on it last class. I'll try it now though.

Posted: Fri Oct 05, 2007 12:57 pm
by eboyd
Is it OK to have a get_T() function? If so, should it be:

Code: Select all

const T get_T(){ return T; }
Mmmmmm.....


who calls this function anyway? Node or List?

me = confused. :?

Posted: Fri Oct 05, 2007 1:46 pm
by Candy
eboyd wrote:Is it OK to have a get_T() function? If so, should it be:

Code: Select all

const T get_T(){ return T; }
Mmmmmm.....


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:

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.

Posted: Fri Oct 05, 2007 4:42 pm
by eboyd
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!