I asked sort of similar question before, but well I'm not gonna lie, was really a jacked up linked list http://www.cplusplus.com/forum/general/182652/. So I remade the whole thing and I think this one is A LOT better so far and so here it is. However, I've come across one problem how do I know where certain element in a linked list are? Before I was cycling through the list just to put in or delete the value, which is not good at all. And one of the good thing that lists are good at is insertion and deletion but how exactly? How are you accessing where to put in or remove an element.
Of course you should check if index is within range, otherwise it's undefined behavior.
There's no magic involved. Cycling through the list is quite a common implementation for list-like structures. For a double linked list you could check if the index is past halfway and iterate backwards in that case for a better preformance. But for single linked lists this is quite a common solution.
I'd probably keep amount as a local variable instead of as a member field, but yes, your approach seems to have linear complexity line the std::list type is guaranteed to at least have.
Another difference is the fact that the links are a separate type from the list now, allowing faster appending (constant time vs linear time). But the insertion is the same .
To answer your question, @OP, that's the disadvantage of linked lists, in that searching must go through at worst, the entire list O(n). Especially since we only see the address of the head node and have to subsequently go through each pointer until we find the address of the value we want.
But after you find said value, inserting and deleting is the easier part where you shift pointers around.
I'd decrease the number of elements when you delete an element (deleteNode). You use increment on eleAmount, whereas I think you meant to decrease the variable. And I'd probably append a space between the elements you output in your showElements function (otherwise the output is harder to read), but that's just a tiny detail.
Other than that, it looks fine at first sight. I can't find any large errors in the code you posted. Of course I could be looking over things, so I'd test the code first though.
My question is, is this a perfectly fine linked list. Anything wrong with it?
In addition to what Shadowwolf said, nC has no business being a member of the class. You use it as a local variable, so make it local to the functions it is used in.
Exceptions should not be used for ordinary flow control as you are doing here.
Why can't you clear an empty list? It would just stay empty.
Why can't you print an empty list? It would just display nothing.
The exceptions in deletenode and insertnode make sense, but only if they're propagated to the calling code (and some version of std::exception or something derived from it would be much better than throwing a string.)
Why do you have member functions with the word node in them? Client code doesn't care about nodes. It wants to insert, delete or add a value, not a node.