LinkedList Help needed

Hi everyone, I am new to this forum. I am normally clueless in programming but I got through the classes somehow just knowing the theory. I can't exactly program too well. In any case, I am in a high level C++ class where I have to code a linked list. I have done what I can by looking at online tuts and stuff but I am not sure if it is what's being asked for and if I need to do something.

Any help would be appreciated.

Here is my LinkedList.cpp (http://pastebin.com/EK72MUTj )
Here is my LinkedList.h (which I am not even sure if I need according to the instructions) [ http://pastebin.com/qVkbsyxB ]

once again, any help would be appreciated. And try not to be too harsh ... I know I should have learned all these things before getting in this class but I am trying now .. so thanks.
Last edited on
if (size == max_size || 100) <= condition will always be true.

Why limit the size of the list arbitrarily?

What you've implemented looks good to me (although it was a very cursory look,) but you also need to implement a destructor, copy constructor and copy assignment operator at a minimum.

Oh yes. Constructors don't have return values, so you'll need to adjust your constructor's prototype in the class definition.

Making member methods const-correct wouldn't hurt, either.

It's one of the requirements that the max size of the LinkedList(LL) is 100.

I am just clarifying that if the size is equal to max (which is 100, like the assignment asks me to do) OR just to be 100% sure, I also put in the actual value of 100. Are you saying that I need to remove that 100 from the if statement?

And isn't my destructor in the printList function?

Do I create a constructor with a struct? If yes then how?

And lastly, do I need the header file? I am not sure if I need it or not.

Once again, I apologize if my questions don't make sense because most of this stuff doesn't make sense to me ... yet.

Thanks for trying Cire,

Waiting for your or any one's reply who can help further.
I am just clarifying that if the size is equal to max (which is 100, like the assignment asks me to do) OR just to be 100% sure, I also put in the actual value of 100. Are you saying that I need to remove that 100 from the if statement?


if (size == max_size || 100)
is equivalent to:
if ((size == max_size) || 100)

and because 100 is non-zero, that part of the condition will always be true.


And isn't my destructor in the printList function?

No. Your destructor will be a member method with prototype: ~linkedList(); It should free all that memory you've been allocating that otherwise would be leaked.


Do I create a constructor with a struct? If yes then how?

The same way you would with a class.


And lastly, do I need the header file? I am not sure if I need it or not.

Yes.
Thank you, I will try to understand what you mean and I will try to learn more.

Cheers!
Topic archived. No new replies allowed.