I'm relatively new to C++, so maybe I'm missing something very obvious, but I can't figure out why I am getting a segmentation fault when I run my program after implementing the copy constructor for a queue. I have the following code for the copy constructor:
Does anyone have any hints/suggestions about why this is causing a segfault? I have been staring at it and playing around with it for hours and just can't seem to figure it out. :-( Any help would be much appreciated. Thanks!Code:Queue::Queue(const Queue& original) { if (original.first_ == NULL) { first_ = (Queue_NodeHolder*) NULL; last_ = (Queue_NodeHolder*) NULL; size_ = 0; } else { Queue_NodeHolder* nh = original.first_; while (nh != NULL) { put(nh->getContent()); nh = nh->getNext(); } } }




Reply With Quote