Doubt on push_back

does push_back only take string-dataype arguments ?

hello @prerak_semwal

no it depends on datatype of container.
for example->
a) vector v;
here datatype is string so we can push string. if it is of some other type then u can push data of that datatype.

@aman212yadav
ok…so is push_back defined in iostream header ?

push back is memory function of string , vector ,deque class etc
its not in iostream

@aman212yadav
ok…
here I used push_back for char datatype then why its not working

u have defined char array , it does not have push_back function.

use c++ string, if u want to use push_back

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.