hi members please tell me what push_back function do , and why it is use

Recommended Answers

All 3 Replies

i believe it can be used to add a node to the end of the queue

The push_back() function of standard container appends to the end of the container the value passed to it. If the size() of the container equals the capacity() of the container then the container will grow to accommodate the new element.

I use the function push_back when dealing with vectors.

Vectors work like arrays, with the exception that you can change the list size during run time.

The Function push_back allows you to enter/insert a copy of a specific element at the end of the list/vector.

The syntax is:

vectorList.push_back(element_to_be_inserted).

But, you can also use it with strings, to insert a value at the end of the string, thus increasing the string size.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.