How to add a string to start of deque in C++

1 Answer

0 votes
#include <iostream>  
#include <string>  
#include <deque> 

int main()
{
	std::deque<std::string> dq;

	dq.assign(5, std::string("c++"));

	dq.push_front("java");

	for (auto elem : dq) {
		std::cout << elem << ' ';
	}
	std::cout << std::endl;

	return 0;
}

/*
run:

java c++ c++ c++ c++ c++

*/

 



answered Jan 4, 2018 by avibootz

Related questions

1 answer 183 views
1 answer 155 views
1 answer 108 views
1 answer 225 views
1 answer 195 views
1 answer 183 views
...