#include <iostream>
#include <string>
static void show_msg(std::initializer_list<std::string> str_list)
{
for (auto beg = str_list.begin(); beg != str_list.end(); ++beg)
{
std::cout << *beg << std::endl;
}
}
int main()
{
show_msg({ "hello", "world", "good", "morning" });
return EXIT_SUCCESS;
}
输出:
hello
world
good
morning