Naming: change ListNode and ListIterator to simply Node and Iterator. List<Something>::ListIterator is redundant.

In your documentation you refer to those as subclasses. This term is understood by most to indicate inheritance. Terms like "inner class" or "nested class" are more appropriate.

In your comparison operators (line 155 in List.h), you pass in a List object. You've done two things wrong. First, the List class is generic, so you need to use List<T>. Second, you're passing them by value, rather than reference. This means a copy will be constructed and passed into the function each time. This is expensive. Using a reference solves that. That reference should be a constant reference also, like so:

code:

bool operator==(const List<T>& one);

Which brings me to... any member functions which can be called without changing the state of the object should have a "const" qualifier.

When dealing with templates, unless I'm out of the loop on a crazy new development, you can't separately compile your List.cpp file. Put the whole thing in one big header file. After all, you're not actually defining any classes or functions... just templates for some that will be created by the compiler as needed.

In the List class, you have:

code:

List<T>::ListNode *headNode,*tailNode;

You're inside the List<T> class, so you can simply write this as:

code:

ListNode *headNode,*tailNode;

Can't find anything else at the moment, but I'll let you know if I do.

Catalyst

Posted: Wed Feb 11, 2004 6:59 am Post subject: (No subject)

Thanks for the tips
They're very helpful

But a few things

As for the naming scheme the inner-classes were originally outside the
main class declaration (and this was part of a larger project) so i felt
that i should have named them that. I guess i got lazy afterward when i
moved them into the class

At the point this was written i had never heard of inherited classes being referred as subclasses, and i thought the term fit here

for the templates i didnt like the idea of having all the code in the
header so i moved it to a .cpp and turned off complilation and linking
on the file (saving as .inl would probably be better tho)

wtd

Posted: Wed Feb 11, 2004 5:23 pm Post subject: (No subject)

Catalyst wrote:

As for the naming scheme the inner-classes were originally outside the main class declaration (and this was part of a larger project) so i felt that i should have named them that. I guess i got lazy afterward when i moved them into the class

Refactoring code sucks, doesn't it?

Catalyst wrote:

At the point this was written i had never heard of inherited classes being referred as subclasses, and i thought the term fit here

Yeah, it's a fairly common way to refer to "child classes".

Speaking of inheritance, you might save yourself a lot of work by inheriting from the std::list class and simply adding the features you want.