Purpose of front() and back() in assigning values in a Queue? (C++)
- by kevin
I have declared:
queue<int, list<int> > Q
After a series of calls:
Q.push(37);
Q.pop();
Q.push(19);
Q.push(3);
Q.push(13);
Q.front();
Q.push(22);
Q.push(8);
Q.back();
I get:
19-3-13-22-8-NULL
What I don't get is what the calls to Q.front() and Q.back() do. From what I understand, they return a reference to the first or last elements respectively, but I dont see how my list would be any different had those calls not been made. Do they have any effect?
Sorry if this seems trivial, but I'm trying to figure out of those calls have a purpose, or of my professor is just trying to screw with me.