+1  A: 

Given the code above, the allocation would read:

node* new_node = new node(winery);

then it's a matter of correctly inserting new_node into your two lists (name and rating) by iterating each separately and setting the pointers correctly.

fbrereto
There must be another way. Main wont work whenever I allocate in that way..
There is no reason code in main would not work because of that change. What error it is?
Eugene
Post the error text!
A. Levy
Im sorry, the code in main does compile. But it gives a debug assertion error.
error C2440: '=' : cannot convert from 'winery' to 'list::node *'
It would help to post the line that caused the error, too.
fbrereto
node *new_node = new node( winery );
The error is a linker error. Because their is no body for the node ctor. I cant make one. And if i did i get a debug assertion error in main when reading the second statement:wineries->insert(winery("Gallo", "Napa Valley", 200, 25));A window pops up with a debug assertion error message.
Wait, what? You don't have a constructor body for node, you can't implement your own, and you disable compiler generated one (by defining copy constructor). You can't create Node (unless you fill in another struct with same exact layout and cast it, but don't do that).You can always remove node constructor definition, and access members directly. (this will enable compiler to generate default constructor)
Eugene
FIXED. THANKS FOR YOUR HELP!! See edit.. =)
sorry. I had crap code in the ctor at one point. Didnt realize the memory leak. That was the problem in main...
+1  A: 

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.

A. Levy
A: 

To specify winery such that a default constructor is not necessary:

Option 1: Specify default values for each parameter in its constructor:

winery(const char * const name = "",
       const char * const location = "", 
       const int acrces = -1,
       const int rating = -1);

Note that if you go this route you'll have to add support code to check and make sure your winery's data is valid.

Option 2: The other option to take is to eliminate the case that requires the default constructor. To find it/them, put the default constructor in the private space of the winery struct, and see where the compiler emits an error. Those instances of winery will need valid initial constructor data.

fbrereto
The problem with providing default values for the fields as in option1 is that it opens other possibilities: now you can create a winery with no parameters or with 4 parameters as in the question, but also with 1, 2 or 3 parameters that could make sense or not. The constructor should also be explicit as it can be called with a single argument. To me the questioners decision to provide both a no argument and a 4 argument constructor explicitly is sound.
David Rodríguez - dribeas