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 251 views
1 answer 174 views
1 answer 152 views
3 answers 323 views
1 answer 186 views
1 answer 160 views
...