Timeline for Implementation of a queue
Current License: CC BY-SA 4.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 12, 2018 at 17:41 | comment | added | maufcost | About copying the contents from one queue to another (using the overloaded assignment operator): Is there a default behavior when it comes to the size of both queues? My intention was to copy everything from a rhs queue to the lhs queue (even the size). So, let's say a rhs queue has size 8, and a lhs has size 3. After the assignment, both would have size 8. Is that "allowed"? | |
May 12, 2018 at 17:37 | vote | accept | maufcost | ||
May 12, 2018 at 14:16 | history | edited | Edward | CC BY-SA 4.0 |
corrected bug cause
|
May 12, 2018 at 14:13 | comment | added | Edward |
You're right. I was misinterpreting what I saw. The real problem is that _firstInQueue is not properly initialized on a copy. I've updated my answers.
|
|
May 12, 2018 at 13:26 | comment | added | Cris Luengo |
Yes, but that is the array that holds the T elements. It doesn’t hold pointers. It holds one pointer, to a piece of memory that seems correctly managed by the class. T s are copied over, but they don’t “point to objects that have been deleted”, they are the objects being held in the container.
|
|
May 12, 2018 at 2:42 | comment | added | Edward |
Internally, the code includes T * _queuePointer;
|
|
May 12, 2018 at 0:44 | comment | added | Cris Luengo |
“Your queue holds pointers”... I don’t see this. Unless the user specifically creates a Queue<int*> or something like this.
|
|
May 11, 2018 at 14:58 | history | answered | Edward | CC BY-SA 4.0 |