How to create and use multiset container for strings in C++

1 Answer

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

int main()
{
	std::multiset<std::string> prog_lang{ "c++", "c", "assembly" };

	for (const auto& elem : prog_lang) {
		std::cout << elem << "  ";
	}
	std::cout << std::endl;

	prog_lang.insert( { "python", "java", "c#", "php" } );

	for (const auto& elem : prog_lang) {
		std::cout << elem << "  ";
	}
	std::cout << std::endl;

	return 0;
}

/*
run:

assembly  c  c++
assembly  c  c#  c++  java  php  python

*/

 



answered Dec 27, 2017 by avibootz

Related questions

2 answers 269 views
1 answer 188 views
1 answer 172 views
3 answers 343 views
1 answer 206 views
1 answer 179 views
...