CODE: http://pastebin.com/d685a1173
I can't seem to figure out why head==NULL is never true (line 58) and why line 74 produces a seg. fault...
thanks in advance for any help...
CODE: http://pastebin.com/d685a1173
I can't seem to figure out why head==NULL is never true (line 58) and why line 74 produces a seg. fault...
thanks in advance for any help...
Is there anyway I can make the default constructor initialize the members for all the overloaded functions?
You need to fix the other constructor instead.Is there anyway I can make the default constructor initialize the members for all the overloaded functions?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
I fixed it as follows: http://pastebin.com/d3542c5db
What's the main thing I am doing wrong?
To begin with, the correct way to initialise the member variables in the default constructor is by using an initialisation list:
Now, in your constructor that takes two int arguments, head must surely be either NULL or uninitialised, so I am not sure why you check if head is equal to NULL. You can still initialise head to NULL using the initialisation list if you want, but there is no need to check if it is NULL.Code:polyType::polyType() : head(NULL), currNode(NULL), currPtr(NULL) {}
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)