I had to apply a circular queue for the class. When I check it, the program properly accepts and decouces. But whenever I create a new object and set it equal to the other, everything prints properly, but it crashes with an error at the end:
Expression : _BLOCK_TYPE_IS_VALID (pHd -> nBlockUse) I started the debugger and it says that the problem is in a row in the decryption function. Here's the function.
excluding zero: Dequeue () {if (Isempty ()) {cout & lt; & Lt; "Queue is empty, there is nothing to be removed." & Lt; & Lt; Endl; Return; } If ((Ismati ()) & amp; amp ;; (front == back)) // When there is only 1 item in the queue, {// remove the same node back and forth; // but that 1 item will be zero due to front = back = 0; Return; } Qnode * p = front; Front = front - & gt; the upcoming; Remove p; // & lt; ---------- Debugger points are here *************************************************************************************** **************************** Return; } As I said, until I create a new object and this task works fine to do this
cquue j = k ; // An encode and decay after this task, but it crashes Is there a coding manufacturer that is a problem?
QWAY: QVO (CUE and original) / / If I put some reason in Const1 in the front = back = 0 parameter, then it will not be compiled; // so I took it out (* this) = original; Front - & gt; Prev = back; Back - & gt; Next = front; }
In your copy constructor, you do the following:
(* this) = Original; This means that your front indicator QoWO j and QWiew K both indicate < Em> same memory When void CQUEUE :: Dequeue () is called for both j and k In addition, your copy maker should be declared as a const / code>. QWai :: QwuI (ConstaQue and Original) . It is difficult to say without much code, but in your copy constructor you need to create deeper copies of pointers (assigning memory using new ). Reading can help.
Comments
Post a Comment