Why is queue a pointer variable in Queue Management assignment (parts 1 and 2) (C++)
I have finished Queue Management parts 1 and 2 in the C++ course, but I am treating q.queue and q.size the same way I would do if I didn't know about pointers. The class Queue contains: class Queue { int size; int* queue; (...) And I solved Part 2 (operator method) as below. I have called both size and queue with the "this" element. So what is the difference between the two variables? One is a pointer, so it should be treated differently somehow? Or, as I suspect, when we access q.queue[i], we are implicitly using the i-th element of the array by reference? Queue operator+(Queue q2) { // Create Queue object to return Queue q3; // Fill q3 from q1 info q3.size = this->size; q3.queue = this->queue; // Fill the rest of the queue with the second object for (int i = 0; i < q2.size; i++) { q3.queue[q3.size] = q2.queue[i]; q3.size++; } // Output of function return q3; }