C++11 string initialization
c++, c++11, string
Solution
std::string myString = {100, 'A'};
is initialization using initializer list. It creates a string with 2 characters: one with code 100 and 'A'
std::string myString(100, 'A');
calls the following constructor:
string (size_t n, char c);
which creates a string with 100 'A's
Problem
I need to create a string of 100 A characters. Why does the following ``` std::string myString = {100, 'A'}; ``` give different results than ``` std::string myString(100, 'A'); ``` ?