I have written the code to execute the queue with a written list, but there are some bugs in this that I can not understand. When I first press a item in the queue, it works, but when I try to push the other, I get a runtime error Can you please help me? Thanks a lot! The following code is:
#include & lt; Iostream & gt; using namespace std; Template & lt; Typename T & gt; Structure node {t data; Node * next; Node (td, node * n = null): data (d), next (n) {}}; Template & lt; Typename T & gt; Class HEQ {Private: Node & Lt; T & gt; * First; The node's & lt; T & gt; * Last; Public: muke () {} zero push (t da) {if (first == faucet) {first = new node & lt; T & gt; (Da); Last = first; } And (last-> next = new node (da); last = last-> next;}} zero pop () {if (last! = NULL) {node & lt ; T & gt; * Temp = First; First = Next> Delete Temp;}} Zero Front () {If (First! = Null) COAT & lt; First & gt; Data;} Bool Isempty () {last last == NULL;}}; int main () {myqueue int> q.push (1); q.push (2); q.front (); / * Q.push (3); q.push (4); q.push (5); Court & lt; q.front ();
Your first and last points are undefined, so your undefined behavior is members Get started with the initial list: myqueue :: myqueue (): first (tap), last (faucet) {}
No comments:
Post a Comment