-
how to copy a queu?
hellow there .. i am new here and i do like this web
actually i am a student and i need help with c++ :confused:
how can i copy a queue then using the assignment operatopr (=) in my code?
i don`t need an algorithem i need functions please
thanks alot
-
Pretty easy, for some type T:
Code:
std::queue<T> queue1;
// ...
std::queue<T> queue2(queue1); // copy construction
std::queue<T> queue3;
queue3 = queue1; // copy assignment
-
Use a constructor:
Code:
std::queue<my_type> queue (other_queue);
(Too late)
-
so to copy a queue i should use a
1)default constructor
2)copy constructor
then to use the = operatoer
queue3 = queue1;
as simple as that?
-
More like: prefer to use the copy constructor. But if you already have a queue, use the copy assignment operator.
-
thanks alot laserlight ;*
great chance to have u as a tutor
-