I'm a little confused by this question. Why do you need to default construct a node? Use the supplied constructor that takes a winery. Like fbereton suggested in his answer.
node* aNode = new node(aWinery);
You need to use a node pointer (node*
) not a node reference (node&
) since you are going to be explicitly managing the memory in the list data structure. Also, it is not a good idea to set the head pointers to NULL at the beginning of the insert function
headByName = NULL;
headByRating = NULL;
You want to do that in the constructor. Otherwise, you lose the nodes in your list every time you insert.
But on to the error you are describing. It would really help if you post the error you are getting, but it sounds like the node(const winery&) constructor is not defined anywhere and the linker wants you to define it. It sounds like you think you are not allowed to define that constructor because the homework instructions mandate that you use the node as defined. However, I think that the instructions probably mean that you only need to use the given header definition of the node struct. That is, you are given the specifications for node, but you need to implement the details yourself.
One of these details is the constructor implementation. You don't need to modify the header to define the constructor. In one of your .cpp files (list.cpp, main.cpp, winery.cpp, it doesn't matter which) Define the following function
list::node::node(const winery& aWinery)
{
item = aWinery;
nextByName = NULL;
nextByRating = NULL;
}
Now the constructor is defined and that should resolve the link error. As a side note, a lot of your functions have this argument signature: const winery& winery
. Now I don't know exactly what the C++ standard has to say about this, but I'd guess it is illegal to have a variable and a type with the same name. Even if your compiler lets you do it, it is confusing.