-
>> I guess i just cant think in terms of ADT maybe i just need to rethink a different major.
It's up to you to decide whether you made the right choice or not. But if you really are interested in the field, you probably just need to put a bit more effort into study and practice.
>> I have worked a week on this project and the sad thing is almost everyone in the class is having the same problems i am having.
Some teachers are talented at what they do, others are not. Ultimately, though, the onus is on you to learn the material.
-
I got it working!!!!
Atleast, i can start to create a doubly linked list in my insert function now..
Problem is the book doesnt really cover initializer list and the teacher has little notes on it.
Thanks for everyones help! Sorry i didint "Get it" sooner...
Code:
list::node::node(const winery &winery) : item(winery.getName(), winery.getLocation(), winery.getAcres(), winery.getRating())
{
item = winery;
nextByName = NULL;
nextByRating = NULL;
}
Code:
void list::insert(const winery& winery)
{
node* newNode = new node(winery);
-
Congrats on at least getting it started. I think you should read up a bit more on initializer lists and constructors. The Internet has a ton of resources on them.
-
I am trying to insert into a doubly linked list.
why wont it let me use winery for a compare? What could i use to find if
the item already exists?
Code:
void list::insert(const winery& winery)
{
//headByName;
//headByRating;
node *current;
node * trailcurrent;
node * newNode;
bool found;
newNode = new node(winery);
newNode->item = winery;
newNode->nextByName = NULL;
if(headByName == NULL)
{
headByName = newNode;
}
else
{
found = false;
current = headByName;
while(current != NULL && !found)
if(current->item >= winery)
found = true;
else
{
trailcurrent = current;
current = current->nextByName;
}
}
-
Have you define what > means in terms of wineries?
-
No, and i dont know how i would go about doing that.
The book i am using does something like this.